diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 14:03:13 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | e2b18ea6897057bd481f7c59d1617677dc2928e9 (patch) | |
| tree | d1cdd474ac841226297da369bd3730fa4f45e09d /src | |
| parent | 379bb906ad3f40937cffa994b6e3550e43f5491a (diff) | |
| download | pardes-e2b18ea6897057bd481f7c59d1617677dc2928e9.tar.gz pardes-e2b18ea6897057bd481f7c59d1617677dc2928e9.zip | |
A Recent or Jumplist row for a file that shrank lands on its last line, the same by either route, and says so
A +Recent row clamped silently and a Jumplist row missed (has no line N). Both are remembered places now: the look clamps to the file as it is, closed or open, and the message row says <file> has N lines now: at its last.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/look.zig | 12 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 7 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/look.zig b/src/look.zig index 09e371b2..79cbd50d 100644 --- a/src/look.zig +++ b/src/look.zig @@ -1415,13 +1415,21 @@ pub fn reopenAt(p: *Pardes, from: usize, path: []const u8, at: Spot) void { } clearNavigationSelection(p, pane); focusPaneLine(p, id, to, .center); + // Said when the file no longer has the line, closed or open: the place + // is its last line now. + if (at.line > n or at.end_line > n) { + var said: [miss_path_cap + 64]u8 = undefined; + var cut: [miss_path_cap + "…".len]u8 = undefined; + p.setMessage(id, std.fmt.bufPrint(&said, "{s} has {d} lines now: at its last", .{ missText(path, &cut), n }) catch "at its last line"); + } } -/// Whether `pane` is the +Recent list, whose rows are remembered places. +/// Whether `pane` is the +Recent or the Jumplist list, whose rows are +/// remembered places: a look at one clamps to the file as it is now. fn isRecentList(pane: *const Pane) bool { const f = pane.file orelse return false; const o = f.output orelse return false; - return std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Recent }); + return std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Recent }) or std.meta.eql(o.from, panes.Output.Origin{ .cmd = .Jumplist }); } pub fn lookAt(p: *Pardes, id: usize, operand: []const u8) void { diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index e31b9e67..2e6ed6db 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2642,6 +2642,13 @@ test "a remembered place is clamped to the file as it is now, its selection's tw try testing.expect(back.body.vsel.active); // Its ends clamped to the last character, `two`'s `o`, not its newline. try testing.expect(back.body.cur_col <= 2 and back.body.vsel.col <= 2); + try testing.expect(std.mem.indexOf(u8, back.msg[0..back.msg_len], "c.txt has 2 lines now: at its last") != null); + // The same row with the file open: the same place, said the same way. + _ = wr(p, Node.of(rows.serial, .look), loc); + p.sync(); + try testing.expectEqual(back.serial, p.panes[p.active].?.serial); + try testing.expect(back.body.cur_row <= 1); + try testing.expect(std.mem.indexOf(u8, back.msg[0..back.msg_len], "at its last") != null); } test "size is monotonic: growing is never refused, and a size once taken is taken again" { |
