From 2580dd5ea85d86262c94363dfea9f990eaf56196 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 19:21:22 -0300 Subject: Everything a B1 chord does while B1 is down is one undo step B1-B2 then B1-B3 cut and pasted as two undo steps. acme marks the file once per B1 hold (text.c:881, textselect), so the pair is a copy. The chord now takes one undo point when it begins and its edits share it until B1 comes up. Co-Authored-By: Claude Opus 5.5 --- test/panes.zig | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test') 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(); -- cgit v1.3