diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 17:15:30 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 17:17:51 -0300 |
| commit | f94555e9fe69ee7df19ba8d52f0d63cfebb35e07 (patch) | |
| tree | de9d5572b11af2867e6ed5820c44a8839f0c5829 /core/Messages.zig | |
| parent | 514b1ed385cdc2618e68ce13b371f6488a5ee504 (diff) | |
| download | pardes-f94555e9fe69ee7df19ba8d52f0d63cfebb35e07.tar.gz pardes-f94555e9fe69ee7df19ba8d52f0d63cfebb35e07.zip | |
Messages: SPC e keeps the error it walks, so the line it lands on shows the error's mark in its box and its words after the line, as a file open when the build ended does (V2's video, pardes bug 1: `:zig build` from main.zig, then SPC e, landed on report.zig:11 with no ✗ in the box and no `✗ local variable is never mutated` after the line, even seconds later; they came only with another build while the file was open); THE CAUSE: not the file opening later (the mark, Messages.markOf, and the words, body_layer messageGhosts, are drawn each frame from the live messages, whatever file opens when) but Messages.act, which took the error out of the live list as it landed its places (SPEC §10.1's `until Esc, the next error, or SPC e`, the prototype's `m.live = false`), and with it every mark and word it put on its lines, so the line the walk lands on is the one line that never shows them; THE FIX: act keeps the error (its places as the list, the walk as before); it goes with Esc, the next error or its pane's next run (exec.zig), as an error does; SPC e on the landed line then unrolls its detail (UX D13), and a third walks again; RUN (TEST FIRST): reproduced with the installed build (514b1ed385cd, VIDEO's kit in a probe: the notice row read `2 messages · SPC h m` after the landing, no error live); Messages.zig "SPC e keeps the error it walks: ..." says an error at report.zig:5:9 of a temp dir, the file not open, SPC e where jumps walk, and asks the landed pane on line 5, the error still the notice row's, `✗` in its box and `var s = 1; ✗ local variable is never mutated` drawn: fails on the base at Messages.zig:1859 (no error live), passes now; the two SPC e tests that asked the error gone now ask it kept (the new-pane one retires it as Esc would before its question part, an error outranking a question); a user hit it on every failing build walked with SPC e; shell-test -Dtest-filter='SPC e' 16/16; load 0.74
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Messages.zig')
| -rw-r--r-- | core/Messages.zig | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index 6233f7e5..9ba1bc93 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -535,10 +535,12 @@ pub fn answer(p: *Pardes, i: usize, key: u8) bool { /// detail not unrolled, that detail (UX D13); else on the message the /// notice row leads with: an error that names places lands them as a list in pane /// `id`'s walk (Pick's `list`, its word `✗ <cause>` in the trail), the -/// first landed on, n and N walking the rest, and the error goes (a -/// +Search under the pane where jumps do not walk, or for a 9P script: -/// Pick.asked); a question takes the keyboard in its pane's tag; anything -/// else, or nothing, opens the history. +/// first landed on, n and N walking the rest (a +Search under the pane +/// where jumps do not walk, or for a 9P script: Pick.asked), the error +/// kept: its mark and its words at the lines it names are where the walk +/// lands, until Esc, the next error or its pane's next run; a question +/// takes the keyboard in its pane's tag; anything else, or nothing, opens +/// the history. pub fn act(p: *Pardes, id: usize) void { const m = &p.messages; // On a line a message names, its detail not unrolled: unrolled (UX @@ -560,10 +562,6 @@ pub fn act(p: *Pardes, id: usize) void { errdefer rows.deinit(); for (lead.places[0..lead.places_len]) |*place| rows.writer.print("{s}:{d}:{d} {s}\n", .{ place.path.slice(), place.line, place.col, place.text.slice() }) catch |err| return reportError(p, .at(id), "Message", err); const cause = lead.src; - const lead_at = for (m.live[0..m.live_len], 0..) |*s, k| { - if (s == lead) break k; - } else return; - m.remove(lead_at); const content = rows.toOwnedSlice() catch |err| return reportError(p, .at(id), "Message", err); if (pardes.Pick.asked(p)) { defer p.gpa.free(content); @@ -1614,11 +1612,13 @@ test "SPC e on an error that names places lists them under the pane and lands on p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = 'e' } }); while (p.nextEffect()) |_| {} - try std.testing.expect(p.messages.headline() == null); + // The error kept, its lines marked, until Esc. + try std.testing.expect(p.messages.headline() == err); const here = p.paneBySerial(serial).?; const list = p.panes[p.panes[here].?.search_pane orelse return error.NoList].?; try std.testing.expect(std.mem.indexOf(u8, list.file.?.content, "/test.txt:4:1") != null); try std.testing.expectEqual(@as(i32, 1), p.panes[here].?.body.cur_row); + try std.testing.expectEqual(@as(usize, 1), p.messages.retire(&.{.@"error"})); // A question: its tag gets the keyboard. keep(p, .question, serial, "/test.txt", "changed on disk").asks = .disk; try std.testing.expect(p.executeBuiltinLine(here, "Message")); @@ -1657,7 +1657,7 @@ test "where jumps walk, SPC e lands an error's places as a list in the pane's wa for (p.panes) |slot| panes_before += @intFromBool(slot != null); for (" e") |c| p.update(.{ .key = .{ .cp = c } }); while (p.nextEffect()) |_| {} - try std.testing.expect(p.messages.headline() == null); + try std.testing.expect(p.messages.headline() == err); // Landed in this reading pane, no pane made: on the first place, the // list's word in its trail. var panes_now: usize = 0; @@ -1830,3 +1830,48 @@ test "a message too wide for the notice row gives way by its items, each cut sho causeWord(pane, &word); try std.testing.expect(std.mem.endsWith(u8, word.slice(), "\u{2026}")); } + +test "SPC e keeps the error it walks: the file it lands in, not open when the error was said, shows the error's mark in its box and its words after the place's line" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "report.zig", .data = "one\ntwo\nthree\nfour\n var s = 1;\nsix\n" }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + p.settings.jumps = .walk; + _ = try p.setTestFile("main\n"); + p.messages.live_len = 0; + const err = keep(p, .@"error", 0, "@p9 zig build", "exit 2"); + err.places[0] = .{ .line = 5, .col = 9 }; + _ = err.places[0].path.print("{s}/report.zig", .{dir}); + err.places[0].text.set("local variable is never mutated"); + err.places_len = 1; + for (" e") |c| p.update(.{ .key = .{ .cp = c } }); + while (p.nextEffect()) |_| {} + p.sync(); + const id = p.view().active; + const pane = p.panes[id].?; + try std.testing.expect(std.mem.endsWith(u8, pane.file.?.path, "/report.zig")); + try std.testing.expectEqual(@as(i32, 4), pane.body.cur_row); + // The error lives on (Esc, the next error or its pane's next run take + // it): the line it names is marked where the walk landed. + try std.testing.expect(p.messages.headline() != null and p.messages.headline().?.kind == .@"error"); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const s = try p.render(frame.allocator()); + const r = p.view().rects[id]; + try std.testing.expectEqualStrings("\u{2717}", s.at(r.x + config.GUTTER - 1, p.tagTop(pane, r)).grapheme()); + var buf: [512]u8 = undefined; + const marked = for (0..s.rows) |y| { + var n: usize = 0; + for (0..s.cols) |x| { + const g = s.cells[y * s.cols + x].grapheme(); + if (n + g.len > buf.len) break; + @memcpy(buf[n..][0..g.len], g); + n += g.len; + } + if (std.mem.indexOf(u8, buf[0..n], "var s = 1;") != null) break buf[0..n]; + } else return error.LineNotShown; + try std.testing.expect(std.mem.indexOf(u8, marked, "var s = 1; \u{2717} local variable is never mutated") != null); +} |
