summaryrefslogtreecommitdiff
path: root/src/Output.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 11:09:17 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit5db9e71ba32dd6f0a0292eaa341d1d8ba805483c (patch)
treefeaf11471f49fdba5122922a960889ea4cb4f549 /src/Output.zig
parent6b46d0797003585a99f8e5b99b3e8cff635ebebc (diff)
downloadpardes-5db9e71ba32dd6f0a0292eaa341d1d8ba805483c.tar.gz
pardes-5db9e71ba32dd6f0a0292eaa341d1d8ba805483c.zip
A remembered place is clamped to the file as it is now, its selection's two ends kept
A Recent row or a jumplist entry for a line the file no longer has failed the look; now it opens at the last line. The selection's anchor is remembered too, so a reopen restores both ends where they fit, and Recent and Jumplist share the (closed) marker. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/Output.zig')
-rw-r--r--src/Output.zig19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Output.zig b/src/Output.zig
index 3b8e6a7a..e6d6f46c 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -555,13 +555,20 @@ pub fn recentText(p: *Pardes, w: *std.Io.Writer, look_rows: bool) !void {
for (p.panes) |slot| if (slot) |pane| if (pane.file) |f| if (f.output == null and std.mem.eql(u8, f.path, e.path)) {
is_open = true;
};
- const state: []const u8 = if (is_open) "open" else "closed";
- if (!look_rows)
- try w.print("{s} {s}\n", .{ state, e.path })
- else if (e.line == 0)
- try w.print("{s} {s}\n", .{ e.path, state })
- else
+ const state: []const u8 = if (is_open) "open" else "(closed)";
+ if (!look_rows) {
+ try w.print("{s} {s}\n", .{ if (is_open) "open" else "closed", e.path });
+ } else if (e.line == 0) {
+ try w.print("{s} {s}\n", .{ e.path, state });
+ } else if (e.aline != 0 and (e.aline != e.line or e.acol != e.col)) {
+ // A selection: both its ends, in order, `path:L:C-L2:C2`.
+ const a_first = e.aline < e.line or (e.aline == e.line and e.acol < e.col);
+ const s = if (a_first) [2]u32{ e.aline, e.acol } else [2]u32{ e.line, e.col };
+ const t = if (a_first) [2]u32{ e.line, e.col } else [2]u32{ e.aline, e.acol };
+ try w.print("{s}:{d}:{d}-{d}:{d} {s}\n", .{ e.path, s[0], s[1], t[0], t[1], state });
+ } else {
try w.print("{s}:{d}:{d} {s}\n", .{ e.path, e.line, e.col, state });
+ }
}
}