summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/panes.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 166e12c9..d8dab298 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -1057,6 +1057,44 @@ const ClickCursorTests = struct {
p.update(.{ .mouse = .{ .button = button, .kind = .release, .col = x, .row = y } });
}
+ test "everything a B1 chord does while B1 is down is one undo step" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 60, .rows = 12 });
+ defer p.deinit();
+ const pane = try p.setTestFile("one two three\n");
+ var frame = std.heap.ArenaAllocator.init(p.gpa);
+ defer frame.deinit();
+ _ = try p.render(frame.allocator());
+ const rect = p.rects[0];
+ const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
+ const y = p.bodyTop(pane, rect);
+ const M = struct {
+ fn ev(pp: *Pardes, b: pardes.Mouse.Button, k: pardes.Mouse.Kind, cx: u16, cy: u16) void {
+ pp.update(.{ .mouse = .{ .button = b, .kind = k, .col = cx, .row = cy } });
+ }
+ };
+ // B1-B2 then B1-B3: cut, then paste back: a copy, one step.
+ const before = pane.file.?.history.undo_len;
+ M.ev(p, .left, .press, x + 4, y);
+ M.ev(p, .left, .drag, x + 6, y);
+ M.ev(p, .middle, .press, x + 6, y);
+ M.ev(p, .middle, .release, x + 6, y);
+ M.ev(p, .right, .press, x + 6, y);
+ M.ev(p, .right, .release, x + 6, y);
+ M.ev(p, .left, .release, x + 6, y);
+ try std.testing.expectEqualStrings("one two three\n", pane.file.?.content);
+ try std.testing.expectEqualStrings("two", p.registers.text(p.gpa, '"').?);
+ try std.testing.expect(pane.file.?.history.undo_len <= before + 1);
+ // A cut alone comes back with one Undo.
+ M.ev(p, .left, .press, x + 4, y);
+ M.ev(p, .left, .drag, x + 6, y);
+ M.ev(p, .middle, .press, x + 6, y);
+ M.ev(p, .middle, .release, x + 6, y);
+ M.ev(p, .left, .release, x + 6, y);
+ try std.testing.expectEqualStrings("one three\n", pane.file.?.content);
+ try std.testing.expect(p.executeBuiltinLine(0, "Undo"));
+ try std.testing.expectEqualStrings("one two three\n", pane.file.?.content);
+ }
+
test "a double-click selects a word, a line, a bracketed or quoted text, as acme's" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 60, .rows = 12 });
defer p.deinit();