diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-08 21:16:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-08 21:48:19 -0300 |
| commit | 8597144cffab56c35d5c6642899116828d0211e6 (patch) | |
| tree | 2d1ab69d47c98c2d49b6af8996a63c651672f5eb | |
| parent | 24b8178d7ba0db8b0ec38769f859e9f47afbfa62 (diff) | |
| download | pardes-8597144cffab56c35d5c6642899116828d0211e6.tar.gz pardes-8597144cffab56c35d5c6642899116828d0211e6.zip | |
fix: Follow's cursor past a page could hop into a collapsed page of the chain, which shows nothing (a collapsed page counted as an empty page): the chain flows past collapsed pages, its hops and ends skip them, and each keeps its scroll until it opens; reference.typ's Follow says what it does not do (a line longer than a page shows its start only, as in any pane; a hop leaves one cursor; two views ordering the pages differently); a behaviour test collapses the last of three pages
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | docs/typ/reference.typ | 12 | ||||
| -rw-r--r-- | src/File.zig | 16 | ||||
| -rw-r--r-- | test/behaviour/follow.zig | 21 |
3 files changed, 47 insertions, 2 deletions
diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 7ffbd3ea..b1532424 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -649,7 +649,17 @@ on its tag: it takes the pane out, a plain twin with the scroll it has, and the chain closes up. #word("Del") of a page leaves the chain too; the first page left is the head, whose tag has no #word("Unfollow"), and a chain of one is none. The chain is kept across #word("Dump") and #word("Restore"); -each window or terminal on the session scrolls its own. +each window or terminal on the session scrolls its own. A collapsed page +shows no text: the chain flows past it, and it takes its place again when +it opens. + +What it does not do: a line longer than a whole page shows its start only, +as in any pane (a pane scrolls by whole lines), and the next page starts on +the line after it. A hop to another page leaves one cursor there, a +multi-cursor selection let go, as an edit through a twin does. Two windows +or terminals that order the pages' columns differently each scroll by their +own order, and the edges a cursor hops at are those of whichever stepped +last. == Addresses and data <addresses> diff --git a/src/File.zig b/src/File.zig index c80e5c42..553f34e4 100644 --- a/src/File.zig +++ b/src/File.zig @@ -1351,6 +1351,21 @@ fn followChain(p: *Pardes, twin: u32) void { } // The head is the text's first page, never a follower of another. dropUnfollow(chain[0]); + // A collapsed page shows no text: the chain flows past it, its cursor + // never hops into it, and it keeps its scroll until it opens again. + var shown: usize = 0; + for (chain[0..n], ids[0..n]) |pane, id| { + if (pane.collapsed) { + pane.follow_edges = 0; + pane.follow_crossed = false; + continue; + } + chain[shown] = pane; + ids[shown] = id; + shown += 1; + } + n = shown; + if (n == 0) return; // The cursor moved past its page's edge: the keyboard goes to the page // showing its line, else to the chain's end, which scrolls to it. const active = for (ids[0..n], 0..) |id, k| { @@ -1412,7 +1427,6 @@ fn followChain(p: *Pardes, twin: u32) void { /// or that line again when the pane wraps it on past its bottom. fn pageEnd(pane: *Pane) usize { const f = &pane.file.?; - if (pane.collapsed) return f.scroll; geometry(pane); if (pane.wrap_n == 0) return f.scroll + pane.rows; const last = (if (pane.body_visible_rows > 0) @min(pane.wrap_n, pane.body_visible_rows) else pane.wrap_n) - 1; diff --git a/test/behaviour/follow.zig b/test/behaviour/follow.zig index 5f2acb02..22c1c3d5 100644 --- a/test/behaviour/follow.zig +++ b/test/behaviour/follow.zig @@ -148,6 +148,27 @@ test "follow: the cursor past a page's last row takes the keyboard to the next p try expectConsecutive(shown); } +test "follow: a collapsed page is passed over: the cursor past the page before it scrolls the chain, never into the fold" { + var s = try init(); + defer s.deinit(); + const head = try s.focused(); + try s.write(s.at("/pane/{d}/exec", .{head}), "Follow\n"); + const second = try newest(&s); + try s.write(s.at("/pane/{d}/exec", .{head}), "Follow\n"); + const third = try newest(&s); + try s.write(s.at("/pane/{d}/exec", .{third}), "Collapse\n"); + const ps = try pages(&s); + try std.testing.expectEqual(@as(usize, 2), ps.len); + try s.keys(s.at("{d}j", .{ps[0].rows})); + try std.testing.expectEqual(second, try s.focused()); + // Past the second page's last row: the second is the chain's end now. + try s.keys(s.at("{d}j", .{ps[1].rows})); + try std.testing.expectEqual(second, try s.focused()); + const moved = try pages(&s); + try std.testing.expect(moved[0].first > 1); + try expectConsecutive(moved); +} + test "follow: Unfollow leaves a twin with its own scroll and closes the chain up; Del of the head makes the next one head" { var s = try init(); defer s.deinit(); |
