summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig53
1 files changed, 50 insertions, 3 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 25f0f6db..3d2821aa 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -4853,7 +4853,7 @@ const LookResetTests = struct {
try std.testing.expectEqualStrings("needle", selected(pane));
}
- test "Look clears both source and existing destination selections before focus" {
+ test "Look clears the source's click highlight, not its dot, and the destination's selections before focus" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
const source = try p.setTestFile("source\nlines\n");
@@ -4872,9 +4872,12 @@ const LookResetTests = struct {
try seed(destination, "previous destination");
pardes.look.lookAt(p, 0, source.pointer_selections[0].?.raw_text.?);
try std.testing.expectEqual(id, p.active);
- try cleared(source);
+ // The source keeps its dot (acme's look leaves it); the click's
+ // highlight goes.
+ for (source.sel) |selection| try std.testing.expectEqual(.none, selection.state);
+ for (source.pointer_selections) |selection| try std.testing.expect(selection == null);
+ try std.testing.expect(source.body.vsel.active);
try cleared(destination);
- try std.testing.expect(!source.body.vsel.active);
if (range) {
try std.testing.expectEqual(@as(i32, 1), destination.body.cur_row);
try std.testing.expectEqualStrings("rav", selected(destination));
@@ -4890,3 +4893,47 @@ const LookResetTests = struct {
test {
_ = LookResetTests;
}
+
+test "a terminal keeps its tag and two body rows through a squeeze, a drag and a smaller window; a text pane does not" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
+ defer p.deinit();
+ p.presentation.enabled = false;
+ p.sync();
+ while (p.nextEffect()) |_| {}
+ const term = for (p.panes, 0..) |slot, i| {
+ if (slot) |pane| if (pane.isTerminal()) break i;
+ } else return error.NoTerminal;
+ p.newScratchBelow(term);
+ p.sync();
+ while (p.nextEffect()) |_| {}
+ const col = layout.findPane(p, term).?.col;
+ const floor = p.panes[term].?.tag_rows + layout.min_body_rows;
+ // Squeezed by the weights: the others give it its floor.
+ p.panes[term].?.vweight = 0.01;
+ for (p.col_panes[col][0..p.col_n[col]]) |k| if (k != term) {
+ p.panes[k].?.vweight = 1000;
+ };
+ p.sync();
+ try std.testing.expectEqual(floor, p.rects[term].h);
+ var rows: ?u16 = null;
+ while (p.nextEffect()) |effect| if (effect == .resize_pty and effect.resize_pty.pane == term) {
+ rows = effect.resize_pty.rows;
+ };
+ try std.testing.expectEqual(@as(?u16, layout.min_body_rows), rows);
+ // A drag of the grip under it up to its tag stops at the floor; one
+ // the other way takes a text pane down to its tag alone.
+ const k = layout.findPane(p, term).?.idx;
+ if (k + 1 < p.col_n[col]) {
+ layout.applyRowSplit(p, col, k, p.rects[term].y);
+ p.sync();
+ try std.testing.expectEqual(floor, p.rects[term].h);
+ const text = p.col_panes[col][k + 1];
+ layout.applyRowSplit(p, col, k, p.screen_h);
+ p.sync();
+ try std.testing.expect(p.rects[text].h <= p.panes[text].?.tag_rows);
+ }
+ // A window too short for all: the terminal keeps its floor still.
+ p.update(.{ .resize = .{ .cols = 100, .rows = 10 } });
+ p.sync();
+ try std.testing.expect(p.rects[term].h >= p.panes[term].?.tag_rows + layout.min_body_rows);
+}