summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig
index f00b35c4..25f0f6db 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -1733,6 +1733,32 @@ test "paste into pane commands and prompts never inserts into the body" {
try std.testing.expect(std.mem.indexOf(u8, pardes.tagline.curTail(pane), " Custom\nCommand") != null);
}
+test "a tag that exactly fills its row stays one row, its caret at the edge as acme's tick" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 50, .rows = 12 });
+ defer p.deinit();
+ const pane = try p.setTestFile("body\n");
+ const width = pardes.tagline.tagWidth(p, 0);
+ // Pad the path until the whole tag is exactly the row.
+ const bare = try pardes.tagline.tagText(p, p.scratch.allocator(), pane);
+ const pad = width - bare.len + pane.file.?.path.len;
+ p.gpa.free(pane.file.?.path);
+ const path = try p.gpa.alloc(u8, pad);
+ @memset(path, 'a');
+ path[0] = '/';
+ pane.file.?.path = path;
+ try std.testing.expectEqual(width, (try pardes.tagline.tagText(p, p.scratch.allocator(), pane)).len);
+ p.update(.{ .key = .{ .cp = ':' } });
+ p.update(.{ .key = .{ .cp = 'A' } });
+ var arena = std.heap.ArenaAllocator.init(p.gpa);
+ defer arena.deinit();
+ const surface = try p.render(arena.allocator());
+ try std.testing.expectEqual(@as(u16, 1), pane.tag_rows);
+ // The layer's caret is past the last character; the grid's, on the pane's
+ // last cell, since it has none past it.
+ try std.testing.expectEqual(@as(u16, @intCast(width)), surface.tag_layers[0].cursor.?.x);
+ try std.testing.expectEqual(p.rects[0].x + p.rects[0].w - 1, surface.cursor.?.x);
+}
+
test "a long pane tag wraps onto rows, and a click on a wrapped row maps to the whole tag's address" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 50, .rows = 12 });
defer p.deinit();