From 8597144cffab56c35d5c6642899116828d0211e6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 8 Nov 2026 21:16:54 -0300 Subject: 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 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/File.zig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') 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; -- cgit v1.3