diff options
| author | Gabriel Schneider <[email protected]> | 2026-07-31 02:59:58 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-01 15:02:08 -0300 |
| commit | f2b8a25d0a25df778bce57efa4c2c7282c71893b (patch) | |
| tree | 9f4c4ad3bddac13e4b32cb984ec390a7430c87e9 /src/pardes.zig | |
| parent | 7022d738dba00049e820e969cabc34ecbeaea465 (diff) | |
| download | pardes-f2b8a25d0a25df778bce57efa4c2c7282c71893b.tar.gz pardes-f2b8a25d0a25df778bce57efa4c2c7282c71893b.zip | |
a new file splits the doc column you were last working in
placeDoc picked its source by SLOT INDEX — it scanned panes from 0 and took the
first doc it found — so which column your file landed in depended on internal
id allocation, not on where you had been. It now walks the jump stack backwards
to the newest live doc pane.
No new state: jumps already IS the record of where the keyboard has been, and
Pane.serial is already the "this slot was reused" test. The slot-order scan
stays as the fallback, deliberately: a restored dump has one jump entry, and if
that pane is a shell the stack knows no doc — without the fallback the next
file would claim a second column with docs already open.
lookpanes moved: a file now lands under the doc that was actually last read
rather than under whichever doc happened to hold the lowest pane id. New
golden doccol pins the case the line exists for, and it fails at exactly one
capture with the walk disabled.
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 47892108..cd01187b 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5227,17 +5227,49 @@ pub const Pardes = struct { /// lands right below `from_id`, be that a shell, a file or another list, /// and `from_id` alone pays the rows (several lists just stack there). /// A real doc joins the docs: any doc already open is the split parent (the - /// source if it IS one, else the first found) and the newcomer lands right - /// below it, so all docs share one column. The FIRST doc of the session - /// instead gets a column of its own on the left (acme: files left, shells - /// right) — nothing is displaced, the other columns just narrow. A full - /// column bar, or a result list whose source died, stacks into the leftmost. + /// source if it IS one, else the one most recently worked in) and the + /// newcomer lands right below it, so docs share a column. The FIRST doc of + /// the session instead gets a column of its own on the left (acme: files + /// left, shells right) — nothing is displaced, the other columns just + /// narrow. A full column bar, or a result list whose source died, stacks + /// into the leftmost. pub fn placeDoc(p: *Pardes, from_id: usize, free: usize, nt: *Pane) void { const doc = if (nt.file) |f| output_pane.fileTraits(f.output).doc else true; // an image is a doc var src_id: ?usize = null; if (p.panes[from_id]) |src| if (if (src.file) |f| output_pane.fileTraits(f.output).doc else src.image != null) { src_id = from_id; }; + // Opened from somewhere that is NOT a doc (a shell, a results list): + // the file joins the column it was last being READ in, which is the + // newest doc on the jump stack. The stack already IS that record — it + // is where the keyboard has been — so nothing new is remembered here; + // asking it is the whole change. What this replaces was the first doc + // in slot order, i.e. pane-id ALLOCATION order, so which column your + // file landed in depended on how the session had handed out ids rather + // than on where you were working. + // + // The answer wanted is the COLUMN, and it stays right once the pane + // itself is closed: trackJump compacts dead entries out, so the walk + // falls through to the next doc remembered in that same column. The + // serial test is the one trackJump uses — slots are reused, so an entry + // whose pane has been replaced names a pane that is gone, not the + // newcomer sitting in its slot (`free`, this very pane, among them). + if (doc and src_id == null) { + var n = p.njumps; + while (n > 0) : (n -= 1) { + const j = p.jumps[n - 1]; + const pp = p.panes[j.pane] orelse continue; + if (pp.serial != j.serial) continue; + if (if (pp.file) |f| output_pane.fileTraits(f.output).doc else pp.image != null) { + src_id = j.pane; + break; + } + } + } + // A doc no jump remembers is still a doc: a restored session focuses + // one pane, not each, and the stack is finite. The rule that a second + // doc never claims a second column outranks knowing where you were, so + // the old slot-order scan stays as the fallback. if (doc and src_id == null) for (p.panes, 0..) |sl, i| { if (sl) |pp| if (i != free and (if (pp.file) |f| output_pane.fileTraits(f.output).doc else pp.image != null)) { src_id = i; |
