diff options
Diffstat (limited to 'test/panes.zig')
| -rw-r--r-- | test/panes.zig | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig index 233e7627..166e12c9 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -1057,6 +1057,43 @@ const ClickCursorTests = struct { p.update(.{ .mouse = .{ .button = button, .kind = .release, .col = x, .row = y } }); } + 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(); + const pane = try p.setTestFile("call foo_bar(a, b)\nsay \"hi there\"\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 Want = struct { col: u16, row: u16, text: []const u8 }; + for ([_]Want{ + .{ .col = 6, .row = 0, .text = "foo_bar" }, + .{ .col = 13, .row = 0, .text = "a, b" }, + .{ .col = 0, .row = 0, .text = "call foo_bar(a, b)\n" }, + .{ .col = 5, .row = 1, .text = "hi there" }, + }) |w| { + click(p, .left, x + w.col, y + w.row); + click(p, .left, x + w.col, y + w.row); + try std.testing.expectEqualStrings(w.text, pardes.edit.currentSelText(p, pane).?); + // A third click is a plain click again: the caret, no selection. + click(p, .left, x + w.col, y + w.row); + try std.testing.expect(!pane.body.vsel.active); + } + // In the tag too. + const tag_text = try pardes.tagline.tagText(p, frame.allocator(), pane); + const del: u16 = @intCast(std.mem.indexOf(u8, tag_text, "Del").? + 1); + const tag_x = rect.x + pardes.TAG_TEXT_INSET + del; + click(p, .left, tag_x, p.tagTop(pane, rect)); + click(p, .left, tag_x, p.tagTop(pane, rect)); + try std.testing.expect(pane.tag.vsel.active); + const tag_now = try pardes.tagline.tagText(p, frame.allocator(), pane); + const a = modal.offsetAt(tag_now, .{ .row = @intCast(pane.tag.vsel.row), .col = @intCast(pane.tag.vsel.col) }); + const h = modal.offsetAt(tag_now, .{ .row = @intCast(pane.tag.cur_row), .col = @intCast(pane.tag.cur_col) }); + try std.testing.expectEqualStrings("Del", tag_now[a .. h + 1]); + } + test "click cursor and insertion agree beyond line and file ends" { for ([_]bool{ false, true }) |already_insert| { for ([_]bool{ false, true }) |bottom_tag| { |
