diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 19 |
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 } }); |
