From f3405aaef8db79094b2741a9caaeaa5328ab6288 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 24 Oct 2026 13:47:11 -0300 Subject: Store 2/3: one bounded store every window shares (Store.zig): Recent as records read on use, the panes a session closes kept as one-pane dumps; Panes lists them (closed), Enter or a look at @pN brings one back beside the pane that took its rows An append-only log under $XDG_STATE_HOME/pardes/store, framed records with a CRC, flock on store.lock (never blocking a step), a stat on use, garbage passed over and compacted away by the next writer, compaction by rename, 100 MiB cap. dump.dumpPane/restorePane lifted out of dumpState/initDump; layout.giveBack; Options.recent_path is store_path. Host calls yield one at a time; /recent refreshes only when no step is out. Tests: two windows and a busy lock, the cap, garbage/torn/partial records, a closed pane's reopen with the layout invariant; fs.py: two live sessions over 9P. --- src/look.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/look.zig') diff --git a/src/look.zig b/src/look.zig index cd8df4fc..ede7d910 100644 --- a/src/look.zig +++ b/src/look.zig @@ -1813,8 +1813,12 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { switch (found) { .none => lookUnresolved(p, id, pane, trimmed, std.mem.trimEnd(u8, txt, "\r\n")), .pane => |t| { - // `@p` names no open pane: a miss, said. - if (t.id >= MAX_PANES or p.panes[t.id] == null) return missed(p, id, "no pane {s}", .{pl.path[0..@min(pl.path.len, 32)]}); + // `@p` names no open pane: one this session closed comes + // back where it was (Store.reopen), any other is a miss, said. + if (t.id >= MAX_PANES or p.panes[t.id] == null) { + if (p.store.closedAddress(pl.path)) |serial| if (p.store.reopen(p, serial, id)) return; + return missed(p, id, "no pane {s}", .{pl.path[0..@min(pl.path.len, 32)]}); + } const target = p.panes[t.id].?; // A PDF's page past its last is a miss, as a line past a file's // end is: never the last page in its place (opening one, the -- cgit v1.3