From da3bc8e006f86889f7abfd55168ce29f1a01e554 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 14:24:33 -0300 Subject: panes: a failed run's message detail is the tool's lines alone, never pardes's own `exit N` under them (UX F2, S2's item 8 reversed by UX2): commandDone fed the run's `exit N` line into the pane, then read its last 400 rows for the report's places, so the detail under the place's line (K, SPC e) ended with `exit 1` (S2 09c), the command's status, which the command's tag and the notice row already say and which in a two-error build hung under the last error only; the rows are read before the status line goes under them (blank rows were never kept: readPlaces skips them); TEST FIRST: panes "a command whose run fails naming places ..." asks the detail to be the report's one line (shell-test, a terminal's: fails on the base at panes.zig:1986, expected 1 row, found 2); a user saw it under every failed build's first error Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/panes.zig | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'core') diff --git a/core/panes.zig b/core/panes.zig index 6fcb15b6..fe127acd 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -1071,6 +1071,14 @@ pub const Pane = struct { } var buf: [16]u8 = undefined; 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). + 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; + } else null; var said: pardes.Kind.Buf(32) = .{}; const lead = if (Term.grid(pane.terminal).cursor_x != 0) "\r\n" else ""; pane.feedOutput(p, said.print("{s}exit {s}\r\n", .{ lead, code })); @@ -1078,21 +1086,17 @@ pub const Pane = struct { p.needs_frame = true; // A failed run whose report names places (a compiler's // `path:line:col: error: ...`): an error of this pane, the places - // its words, the rows after its first its detail (SPEC §10.2). Its - // last rows only: a report's places are at its end. - if (status != 0) if (pane.terminal) |state| report: { - const grid = Term.grid(state); - const first = grid.total -| 400; - const rows = Term.editRows(state, p.scratch.allocator(), first, grid.total - first) catch break :report; + // its words, the rows after its first its detail (SPEC §10.2). + if (rows) |report_rows| report: { var found: pardes.Messages.Said = .{}; - if (pardes.Messages.readPlaces(&found, pane.cwdSlice(), rows) == 0) break :report; + if (pardes.Messages.readPlaces(&found, pane.cwdSlice(), report_rows) == 0) break :report; var words: pardes.Kind.Buf(32) = .{}; const kept = pardes.Messages.say(p, .@"error", id, words.print("exit {s}", .{code})); kept.places = found.places; kept.places_len = found.places_len; kept.detail = found.detail; kept.detail_len = found.detail_len; - }; + } } }; @@ -1981,6 +1985,9 @@ test "a command whose run fails naming places is an error of its pane, those pla try std.testing.expectEqual(@as(u8, 1), said.places_len); try std.testing.expectEqualStrings("/tmp/pardes-cmd/core/pick.zig", said.places[0].path.slice()); try std.testing.expectEqualStrings(" const best = rank(q, name, 3);", said.detail[0].slice()); + // The tool's lines alone: pardes's own `exit 1` under them is the run's + // status, in the command's tag and on the notice row (UX F2). + try std.testing.expectEqual(@as(u8, 1), said.detail_len); var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); const s = try p.render(frame.allocator()); -- cgit v1.3