diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 17:22:04 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 17:22:04 -0300 |
| commit | 6ef1941324aa578750d54567c1ed201ad36412b8 (patch) | |
| tree | a051b6eb8f49ec09fb5799787e008282fa551091 /core/panes.zig | |
| parent | a89de25fb869c2a21289321aff847431e8552906 (diff) | |
| download | pardes-6ef1941324aa578750d54567c1ed201ad36412b8.tar.gz pardes-6ef1941324aa578750d54567c1ed201ad36412b8.zip | |
panes, Messages: a failed run's error names that run's places, each once: a rerun in the same command pane no longer reads the run before it again, and a note at an error's place is not a second place (V2's video, pardes bug 3: after a code action put a line above report.zig's error, a save and `:zig build` again, line 11 still carried `✗ local variable is never mutated` from the build before, and the notice row read `…report.zig:11:9 · …report.zig:11:9 · …report.zig:12:9…`; a rebuild with no edit `…11:9 · …11:9 · …11:9…`); THE CAUSES: the rerun does take the pane's last error away (exec.zig, the same pane, @p2, reused), but Pane.commandDone read the places from the terminal's last 400 rows, which hold the runs before it in that pane (the pane is reused and keeps its rows), so the new error named the old run's places first (the walk landing on the stale line, its words drawn there); and Messages.readPlaces kept every place row, so zig's `note: consider using 'const'` at the error's own place was a second place (`1/2` and `2/2` on one spot, even in a first run); THE FIX: commandDone reads the rows after the run's own `% line` (exec.echoCommand writes it above every run; all the last 400 when it is further up: they are all this run's); readPlaces keeps a place named again (same path, line and column) once, the first's words; RUN (TEST FIRST): reproduced with the installed build in VIDEO's kit (a probe: `11:9 · 11:9` after the first build, `11:9 · 11:9 · 12:9 · 1…` after the edit and rebuild, line 11's stale words); panes.zig "a failed run's error names that run's places, each once: ..." feeds a command pane zig's minimal report for report.zig:11:9 with its note, exits 2, reruns it in the same pane with the report at 12:9, and asks each run's error for exactly its one place, its words and its two detail rows: fails on the base at panes.zig:2029 on the first run (`11:9 11:9`), with readPlaces' fix alone on the rerun (`11:9 12:9`), passes now; the probe with this stack's build: one place each run, the walk on 12:9 after the rebuild, line 11 bare; a user hit it on every rerun of a failing build and with every compiler that adds a note at its error; shell-test -Dtest-filter=place 97/97; load 0.71
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/panes.zig')
| -rw-r--r-- | core/panes.zig | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/core/panes.zig b/core/panes.zig index 280fd3f9..4b9aa7a7 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -1073,11 +1073,21 @@ pub const Pane = struct { const code = if (status) |n| std.fmt.bufPrint(&buf, "{d}", .{n}) catch unreachable else "?"; // an exit status fits 16 // A failed run's last rows, read before its `exit N` goes under // them: a report's places are at its end, and its detail is the - // tool's lines, not the run's status (UX F2). + // tool's lines, not the run's status (UX F2). Its own: those after + // its `% line` (exec.echoCommand), not a run's before it in the + // pane, whose places are no longer where it said. const rows: ?[]const []const u8 = if (status == 0) null else if (pane.terminal) |state| read: { const grid = Term.grid(state); const first = grid.total -| 400; - break :read Term.editRows(state, p.scratch.allocator(), first, grid.total - first) catch null; + const last = Term.editRows(state, p.scratch.allocator(), first, grid.total - first) catch break :read null; + const command = pane.command orelse break :read last; + var from = last.len; + while (from > 0) { + from -= 1; + const echo = std.mem.trimEnd(u8, last[from], " "); + if (echo.len > "% ".len and std.mem.startsWith(u8, echo, "% ") and std.mem.startsWith(u8, command, echo["% ".len..])) break :read last[from + 1 ..]; + } + break :read last; } else null; var said: pardes.Kind.Buf(32) = .{}; const lead = if (Term.grid(pane.terminal).cursor_x != 0) "\r\n" else ""; @@ -2002,3 +2012,37 @@ test "a command whose run fails naming places is an error of its pane, those pla while (p.nextEffect()) |_| {} try std.testing.expect(p.messages.headline() == null or p.messages.headline().?.kind != .@"error"); } + +test "a failed run's error names that run's places, each once: a rerun in the same pane does not read the run before it again, and a note at an error's place is not a second place" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a command pane's terminal + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{}); + defer p.deinit(); + while (p.nextEffect()) |_| {} + p.setCwd(.at(0), "/tmp/pardes-cmd"); + _ = try pardes.Kind.open(p, 1, pardes.Kind.test_kind.of(p), "/tmp/pardes-cmd/pic.ppm", null); + const dst = exec.execute(p, 1, "zig build") orelse return error.NoCommandPane; + while (p.nextEffect()) |_| {} + // `zig build`'s report, ZIG_BUILD_ERROR_STYLE=minimal: the error, its + // source line and caret, a note at the same place; then the same + // error a line lower once a line went in above it. + for ([_]u32{ 11, 12 }) |line| { + var out: [512]u8 = undefined; + p.update(.{ .output = .{ .pane = .at(dst), .bytes = try std.fmt.bufPrint(&out, "report.zig:{d}:9: error: local variable is never mutated\r\n var s = if (c.words == 1) \"\" else \"s\";\r\n ^\r\nreport.zig:{d}:9: note: consider using 'const'\r\nerror: 1 compilation errors\r\n", .{ line, line }) } }); + p.update(.{ .exited = .{ .pane = .at(dst), .status = 2 } }); + const said = p.messages.headline() orelse return error.NothingSaid; + try std.testing.expectEqual(pardes.Messages.Kind.@"error", said.kind); + var names: [256]u8 = undefined; + var w: std.Io.Writer = .fixed(&names); + for (said.places[0..said.places_len]) |*place| try w.print("{s}:{d}:{d} ", .{ place.path.slice(), place.line, place.col }); + var want: [64]u8 = undefined; + try std.testing.expectEqualStrings(try std.fmt.bufPrint(&want, "/tmp/pardes-cmd/report.zig:{d}:9 ", .{line}), w.buffered()); + try std.testing.expectEqualStrings("local variable is never mutated", said.places[0].text.slice()); + try std.testing.expectEqual(@as(u8, 2), said.detail_len); + if (line == 12) break; + // Its next run, in the same pane: the rows above are the last run's. + p.update(.{ .eof = .{ .pane = .at(dst) } }); + try std.testing.expectEqual(@as(?usize, dst), exec.execute(p, 1, "zig build")); + while (p.nextEffect()) |_| {} + } +} |
