summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig32
1 files changed, 21 insertions, 11 deletions
diff --git a/test/panes.zig b/test/panes.zig
index e4e677e4..69628cd9 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -468,7 +468,7 @@ const TreeContextTests = struct {
try std.testing.expectEqual(@as(i32, 59), pane.wrapAt(visible.row).line);
const cursor = surface.cursor orelse return error.MissingLookCursor;
const rect = p.rects[0];
- const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const y = p.bodyTop(pane, rect);
try std.testing.expectEqual(y + @as(u16, @intCast(visible.row)), cursor.y);
}
}
@@ -490,14 +490,16 @@ const TreeContextTests = struct {
try std.testing.expectEqual(@as(i32, 7), pane.wrapAt(pane.context_rows).line);
const rect = p.rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
- const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const y = p.bodyTop(pane, rect);
ClickCursorTests.click(p, .left, x + 6, y);
try std.testing.expectEqual(@as(i32, 0), pane.cur_row);
try std.testing.expectEqual(@as(i32, 6), pane.cur_col);
try std.testing.expectEqual(@as(i32, 7), pane.scroll());
const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextCursor;
try std.testing.expectEqual(x + 6, cursor.x);
- try std.testing.expectEqual(y, cursor.y);
+ // Read the body top again: the click cleared the announcement band the
+ // builtin above put up, and the body moved back up with it.
+ try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y);
p.update(.{ .key = .{ .cp = 'i' } });
p.update(.{ .key = .{ .cp = 'Z', .text = "Z" } });
try std.testing.expect(std.mem.startsWith(u8, pane.file.?.content, "const ZBox = struct {"));
@@ -536,7 +538,7 @@ const TreeContextTests = struct {
const surface = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 3), pane.context_rows);
const rect = p.rects[0];
- const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const y = p.bodyTop(pane, rect);
var glyph_x: ?u16 = null;
for (0..surface.cols) |col| {
if (std.mem.eql(u8, surface.at(@intCast(col), y).grapheme(), "界")) glyph_x = @intCast(col);
@@ -548,7 +550,9 @@ const TreeContextTests = struct {
try std.testing.expectEqual(@as(i32, 8), pane.scroll());
const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextCursor;
try std.testing.expectEqual(x, cursor.x);
- try std.testing.expectEqual(y, cursor.y);
+ // Read the body top again: the click cleared the announcement band the
+ // builtin above put up, so the body moved with it.
+ try std.testing.expectEqual(p.bodyTop(pane, p.rects[0]), cursor.y);
panes.File.setContent(p, &pane.file.?, try p.gpa.dupe(u8, "// no enclosing declaration\n" ** 18));
_ = try p.render(frame.allocator());
try std.testing.expectEqual(@as(u16, 0), pane.context_rows);
@@ -576,12 +580,16 @@ const TreeContextTests = struct {
target = .{ .x = @intCast(col), .y = @intCast(row) };
};
const glyph = target orelse return error.MissingWrappedContextBody;
+ const offset = pane.body_offset;
ClickCursorTests.click(p, .left, glyph.x + 1, glyph.y);
try std.testing.expectEqual(@as(i32, 2), pane.cur_row);
try std.testing.expectEqual(@as(i32, @intCast(std.mem.indexOf(u8, body, "界").?)), pane.cur_col);
const cursor = (try p.render(frame.allocator())).cursor orelse return error.MissingContextBodyCursor;
try std.testing.expectEqual(glyph.x, cursor.x);
- try std.testing.expectEqual(glyph.y, cursor.y);
+ // The scan above ran with the builtin's announcement band up; the click
+ // cleared it, so the row the glyph was found on has moved up with the
+ // body it belongs to.
+ try std.testing.expectEqual(glyph.y - offset, cursor.y);
}
};
@@ -607,7 +615,7 @@ const TtySelectionTests = struct {
_ = try p.render(frame.allocator());
const rect = p.rects[0];
const x = rect.x + config.GUTTER;
- const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const y = p.bodyTop(pane, rect);
JumpSelectionTests.drag(p, x + 1, y, x + 3, y);
try std.testing.expectEqualStrings("lph", p.yank orelse return error.MissingAutomaticTtyYank);
p.update(.{ .key = .{ .cp = p.opts.tty_toggle, .ctrl = true } });
@@ -637,7 +645,7 @@ const TtySelectionTests = struct {
_ = try p.render(frame.allocator());
const rect = p.rects[0];
const x = rect.x + config.GUTTER;
- const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const y = p.bodyTop(pane, rect);
JumpSelectionTests.drag(p, x + @as(u16, if (prompt) 0 else 1), y, x + 3, y + @as(u16, if (prompt) 0 else 1));
const expected = if (prompt) "$ ab" else "lph\nrav";
try std.testing.expectEqual(Pane.Mode.tty, pane.mode);
@@ -952,7 +960,7 @@ const JumpSelectionTests = struct {
if (wrap) try std.testing.expectEqual(pane.wrap_line[0], pane.wrap_line[1]);
const rect = p.rects[0];
const x = rect.x + config.GUTTER + panes.File.gutterWidth(pane);
- const y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const y = p.bodyTop(pane, rect);
if (reverse)
drag(p, x + last_col, y + 1, x + first_col, y)
else
@@ -982,7 +990,9 @@ const JumpSelectionTests = struct {
try std.testing.expectEqual(@as(i32, 0), pane.cur_col);
// A selection created after Back must also disappear on Forward.
- drag(p, x + 1, y, x + 3, y + 1);
+ // Back announces itself, so the body sits under a notice band now.
+ const y2 = p.bodyTop(pane, p.rects[0]);
+ drag(p, x + 1, y2, x + 3, y2 + 1);
try std.testing.expect(pardes.test_api.heldSelection(p, 0) != null);
p.update(.{ .key = .{ .cp = 'i', .ctrl = true } });
_ = frame.reset(.retain_capacity);
@@ -4117,7 +4127,7 @@ test "cancelled normal gestures leave no count or subprefix after mouse and focu
.body, .tag => {
const rect = p.rects[0];
const tag_y = if (p.settings.tag_bottom) rect.y + rect.h - pardes.BOX_H else rect.y;
- const body_y = if (p.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
+ const body_y = p.bodyTop(pane, rect);
const x = rect.x + config.GUTTER + @as(u16, @intCast(panes.File.gutterWidth(pane))) + 3;
const y = if (gesture == .tag) tag_y else body_y;
p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = x, .row = y } });