diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-03 17:45:10 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-03 17:47:54 -0300 |
| commit | 00629bd791b8e41204366a795b6f36a289a45a68 (patch) | |
| tree | fd3bb018a8ff8591cc55eb111057716de6e44f62 /test/behaviour/mouse.zig | |
| parent | 8fe05231e6e683b09b89356d4dff0ddb487962e4 (diff) | |
| download | pardes-00629bd791b8e41204366a795b6f36a289a45a68.tar.gz pardes-00629bd791b8e41204366a795b6f36a289a45a68.zip | |
test: two checks the panes migration dropped though the 9P tree shows them, from a review: a look leaves select mode and the extra cursors behind (mode:normal on the pane's ctl after Cv and a look, a Z typed once), as the old test's cleared() asked of select and nsel; a click past a line's end and on a wide glyph's second cell draws the caret where it lands, and insert mode draws it there too (Session.cursor from /screen), as the old tests compared the render's cursor; each checked to fail against a break (clearNavigationSelection keeping select, keeping nsel; the insert-mode body caret drawn a cell right)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/mouse.zig')
| -rw-r--r-- | test/behaviour/mouse.zig | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/test/behaviour/mouse.zig b/test/behaviour/mouse.zig index 27185409..13c9b631 100644 --- a/test/behaviour/mouse.zig +++ b/test/behaviour/mouse.zig @@ -54,11 +54,11 @@ test "mouse: everything a B1 chord does while B1 is down is one undo step" { test "mouse: a click past a line's or the file's end puts the caret where insertion types" { for ([_]bool{ false, true }) |already_insert| { for ([_]bool{ false, true }) |bottom_tag| { - for ([_]struct { text: []const u8, click_row: usize, dot: u32, result: []const u8 }{ - .{ .text = "abc\nxy", .click_row = 0, .dot = 3, .result = "abcZ\nxy" }, - .{ .text = "abc\nxy", .click_row = 5, .dot = 6, .result = "abc\nxyZ" }, - .{ .text = "abc\n", .click_row = 5, .dot = 4, .result = "abc\nZ" }, - .{ .text = "", .click_row = 5, .dot = 0, .result = "Z" }, + for ([_]struct { text: []const u8, click_row: usize, dot: u32, col: usize, row: usize, result: []const u8 }{ + .{ .text = "abc\nxy", .click_row = 0, .dot = 3, .col = 3, .row = 0, .result = "abcZ\nxy" }, + .{ .text = "abc\nxy", .click_row = 5, .dot = 6, .col = 2, .row = 1, .result = "abc\nxyZ" }, + .{ .text = "abc\n", .click_row = 5, .dot = 4, .col = 0, .row = 1, .result = "abc\nZ" }, + .{ .text = "", .click_row = 5, .dot = 0, .col = 0, .row = 0, .result = "Z" }, }) |case| { var s = try Session.initFile(std.testing.allocator, case.text); defer s.deinit(); @@ -69,8 +69,11 @@ test "mouse: a click past a line's or the file's end puts the caret where insert const x, const y = try s.where("1 "); try mouse(&s, "m {d} {d} 1\nm {d} {d} 0\n", .{ x + 2 + 15, y + case.click_row, x + 2 + 15, y + case.click_row }); try std.testing.expectEqual(.{ case.dot, case.dot }, try s.range(s.at("/pane/{d}/dot", .{n}))); + // The caret is drawn where it is, and insertion draws it there too. + try std.testing.expectEqual(.{ x + 2 + case.col, y + case.row }, try s.cursor()); if (!already_insert) try s.keys("i"); try std.testing.expect(std.mem.endsWith(u8, try s.read(s.at("/pane/{d}/ctl", .{n})), " mode:insert ")); + try std.testing.expectEqual(.{ x + 2 + case.col, y + case.row }, try s.cursor()); try s.keys("Z"); try s.expect(s.at("/pane/{d}/body", .{n}), case.result); } @@ -95,7 +98,10 @@ test "mouse: a click on a tab's or a wrapped wide glyph's cells puts the caret o try mouse(&s, "m {d} {d} 1\nm {d} {d} 0\n", .{ x + 1, y, x + 1, y }); const at: u32 = @intCast(try std.unicode.utf8CountCodepoints(source[0..std.mem.indexOf(u8, source, "界").?])); try std.testing.expectEqual(.{ at, at }, try s.range(s.at("/pane/{d}/dot", .{n}))); + // Drawn on the glyph's first cell, in insert mode too. + try std.testing.expectEqual(.{ x, y }, try s.cursor()); if (!already_insert) try s.keys("i"); + try std.testing.expectEqual(.{ x, y }, try s.cursor()); try s.keys("Z"); const byte = std.mem.indexOf(u8, source, "界").?; try s.expect(s.at("/pane/{d}/body", .{n}), s.at("{s}Z{s}", .{ source[0..byte], source[byte..] })); |
