summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 11:40:03 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit2f187232227dde2755a7f2f2ce717f3e1f685f5c (patch)
tree0aebb2ad5831e235ab5833b514493878a00faf8c /src/pardes.zig
parentf0fc0be608bb1ee96c20d9f9baaefd2543fed7a2 (diff)
downloadpardes-2f187232227dde2755a7f2f2ce717f3e1f685f5c.tar.gz
pardes-2f187232227dde2755a7f2f2ce717f3e1f685f5c.zip
Recent keeps only files on disk, and its cap never drops an open one
A renamed scratch never saved and a /virtual/ pane were recorded as recent files, and at 200 the oldest entry went even when that file was open. Opens, renames and closes now record a path only when it is a file on this host, and the cap drops the oldest closed entry. A name with a newline is not written to the kept list, where it would read back as two. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 76ec2176..2bf594c4 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4700,6 +4700,21 @@ pub const Pardes = struct {
}
/// A file pane's path and dot, for the recent list (0 when none).
+ /// Whether `path` is one Recent keeps: a file on this host's disk, not
+ /// the served tree's (`/virtual/`) nor a name never saved.
+ pub fn recentKeeps(path: []const u8) bool {
+ const local = filesystem.localPath(path) orelse return false;
+ if (comptime !hosted) return true;
+ return exec.isFile(local);
+ }
+
+ /// A file pane closing: its place noted in Recent, when Recent keeps it.
+ fn noteClosed(p: *Pardes, pane: *const Pane) void {
+ const d = recentDot(pane) orelse return;
+ if (p.recent.get(d.path) == null and !recentKeeps(d.path)) return;
+ p.recent.closedSel(p.recentGpa(), d.path, d.line, d.col, d.aline, d.acol);
+ }
+
fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col: u32, aline: u32 = 0, acol: u32 = 0 } {
const f = pane.file orelse return null;
if (f.output != null) return null;
@@ -4722,7 +4737,7 @@ pub const Pardes = struct {
pub fn deinit(p: *Pardes) void {
// Every file open now is closed with its dot, and the list kept.
- for (p.panes) |slot| if (slot) |pane| if (recentDot(pane)) |d| p.recent.closedSel(p.recentGpa(), d.path, d.line, d.col, d.aline, d.acol);
+ for (p.panes) |slot| if (slot) |pane| p.noteClosed(pane);
p.saveRecent();
p.recent.deinit(p.recentGpa());
look.cancelLookHover(p);
@@ -4835,7 +4850,7 @@ pub const Pardes = struct {
fn retirePane(p: *Pardes, pane: *Pane) void {
// Closed, a file is remembered with its dot: Recent and a jump back
// to it reopen it there.
- if (recentDot(pane)) |d| p.recent.closedSel(p.recentGpa(), d.path, d.line, d.col, d.aline, d.acol);
+ p.noteClosed(pane);
const watched = (if (pane.file) |f| f.output == null else false) or pane.hasPdf();
for (p.panes, 0..) |slot, id| if (slot == pane) {
if (watched) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } });