From 9ba51f2fb70a47dc218a864f8fd188f2585fd6fe Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 19:42:38 -0300 Subject: The jump list never holds two entries in a row the same: when the one between them goes, they are one A closed pane's entry dropped from between two visits to the same place, or a closed file's entry reopened beside its own, left twin entries, and Back spent a press going nowhere while Jumplist listed the place twice. The compaction that drops dead entries now folds a twin into the one before it, keeping the current entry on the one kept. Co-Authored-By: Claude Opus 5.5 --- src/pardes.zig | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index f08cf01b..6a78c115 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -6889,6 +6889,12 @@ pub const Pardes = struct { break; }; } + // Two in a row the same (a closed one reopened beside its own, + // or the entry between them gone): one entry, one step. + if (w > 0 and std.meta.eql(p.jumps[w - 1], kept)) { + if (i == p.jcur) cur = w - 1; + continue; + } p.jumps[w] = kept; w += 1; } @@ -8034,6 +8040,26 @@ test "raw tty Ctrl-B switches to editor mode without sending child input" { try std.testing.expectEqualStrings("", drainWrites(p, &buf)); } +test "the jump list never holds two entries in a row the same, when the one between them goes" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 40 }); + defer p.deinit(); + const pane = try p.setTestFile("a\n" ** 200); + const at: Loc = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 }; + // A, a pane long closed with no file to keep it, A again, then far on. + p.jumps[0] = at; + p.jumps[1] = .{ .pane = 5, .serial = 999, .line = 1, .col = 1 }; + p.jumps[2] = at; + p.jumps[3] = .{ .pane = 0, .serial = pane.serial, .line = 150, .col = 1 }; + p.njumps = 4; + p.jcur = 3; + pane.body.cur_row = 80; // where you are now: far from both + p.trackJump(); + for (1..p.njumps) |i| try std.testing.expect(!std.meta.eql(p.jumps[i - 1], p.jumps[i])); + try std.testing.expectEqual(@as(usize, 3), p.njumps); + try std.testing.expectEqual(@as(u32, 1), p.jumps[0].line); + try std.testing.expectEqual(@as(u32, 150), p.jumps[1].line); +} + test "hopping between two panes does not grow the jump stack" { if (platform == .web) return; const gpa = std.testing.allocator; -- cgit v1.3