summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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;