summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 19:42:38 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit9ba51f2fb70a47dc218a864f8fd188f2585fd6fe (patch)
tree8fc4c6374f76f0f5c54fbe78d47f7cd051903b78 /src/pardes.zig
parent181170ff00a2019465b6401047407d9914b3b631 (diff)
downloadpardes-9ba51f2fb70a47dc218a864f8fd188f2585fd6fe.tar.gz
pardes-9ba51f2fb70a47dc218a864f8fd188f2585fd6fe.zip
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 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig26
1 files changed, 26 insertions, 0 deletions
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;