summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 10:49:58 -0300
committerGabriel Schneider <[email protected]>2026-11-04 11:05:39 -0300
commit9cfebaeca67301a8925eaa44c71859b42b676e59 (patch)
tree9f3e221ac895d9b006031470098d83135e61d7cb /test/panes.zig
parentff0b8a382de7a1994a6912dc71ba28a8ecdaf474 (diff)
downloadpardes-9cfebaeca67301a8925eaa44c71859b42b676e59.tar.gz
pardes-9cfebaeca67301a8925eaa44c71859b42b676e59.zip
test: a tag's file-name tint and Back and Forward through the 9P tree alone: in test/behaviour/tags.zig a file pane's tag tinting its name (界file.zig) and not its directory, dirty marker or words, the tag at the top or the bottom (Session.styles); in keys.zig Ctrl-o and Ctrl-i (Kctl o, i) jumping between line 60 and line 1 made by 60G1G, dot empty where the jump lands and no B1 sweep drawn after either, a wrapped Unicode and tab sweep included, swept either way; each checked to fail against a break (the tint starting at the last slash, focusPaneLine not moving the caret; clearNavigationSelection returning at once is not caught, the key's own path dropping the sweep too); test/panes.zig's two one-pane jump tests deleted, the tint test trimmed to its search pane (fillResults), the cross-pane jump test kept (it seeds held selections)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig76
1 files changed, 5 insertions, 71 deletions
diff --git a/test/panes.zig b/test/panes.zig
index c996ca00..a7ecf994 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -788,75 +788,8 @@ const JumpSelectionTests = struct {
p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = col1, .row = row1 } });
}
- fn exercise(prefix: []const u8, wrap: bool, reverse: bool, first_col: u16, last_col: u16, expected: ?[]const u8) !void {
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 34, .rows = 10 });
- defer p.deinit();
- p.settings.wrap = wrap;
- const text = try std.fmt.allocPrint(p.gpa, "{s}{s}", .{ prefix, std.mem.asBytes(&@as([80][27]u8, @splat("unrelated destination text\n".*))) });
- defer p.gpa.free(text);
- const pane = try p.setTestFile(text);
- var frame = std.heap.ArenaAllocator.init(p.gpa);
- defer frame.deinit();
- _ = try p.render(frame.allocator());
- 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 = p.bodyTop(pane, rect);
- if (reverse)
- drag(p, x + last_col, y + 1, x + first_col, y)
- else
- drag(p, x + first_col, y, x + last_col, y + 1);
-
- const selected = try p.gpa.dupe(u8, pardes.exec.heldSelection(p, 0) orelse return error.MissingMouseSelection);
- defer p.gpa.free(selected);
- if (expected) |want| try std.testing.expectEqualStrings(want, selected);
- try std.testing.expect(std.mem.indexOfScalar(u8, selected, '\n') != null);
- if (wrap) try std.testing.expect(std.mem.indexOf(u8, selected, "界") != null);
-
- // Seed two actual locations after the drag, so both history directions
- // must scroll and discard the previous selection.
- p.njumps = 2;
- p.jcur = 1;
- p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 60, .col = 1 };
- p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 1 };
- p.update(.{ .key = .{ .cp = 'o', .ctrl = true } });
- _ = frame.reset(.retain_capacity);
- _ = try p.render(frame.allocator());
- try std.testing.expectEqual(@as(usize, 0), p.jcur);
- try std.testing.expect(pane.file.?.scroll > 20);
- try LookResetTests.cleared(pane);
- try std.testing.expect(!pane.body.vsel.active);
- try std.testing.expect(pardes.exec.heldSelection(p, 0) == null);
- try std.testing.expectEqual(@as(i32, 59), pane.body.cur_row);
- try std.testing.expectEqual(@as(i32, 0), pane.body.cur_col);
-
- // A selection created after Back must also disappear on Forward.
- // 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.exec.heldSelection(p, 0) != null);
- p.update(.{ .key = .{ .cp = 'i', .ctrl = true } });
- _ = frame.reset(.retain_capacity);
- _ = try p.render(frame.allocator());
- try std.testing.expectEqual(@as(usize, 1), p.jcur);
- try std.testing.expectEqual(@as(usize, 0), pane.file.?.scroll);
- try LookResetTests.cleared(pane);
- try std.testing.expect(!pane.body.vsel.active);
- try std.testing.expect(pardes.exec.heldSelection(p, 0) == null);
- try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row);
- try std.testing.expectEqual(@as(i32, 0), pane.body.cur_col);
- }
-
- test "jump selection clears copied sweeps in both history directions" {
- for ([_]bool{ false, true }) |reverse|
- try exercise("alpha\nbravo\n", false, reverse, 1, 3, "lpha\nbrav");
- }
-
- test "jump selection clears wrapped Unicode and tab rectangles" {
- for ([_]bool{ false, true }) |reverse|
- try exercise("界\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n", true, reverse, 0, 8, null);
- }
-
+ // One pane's Back and Forward are test/behaviour/keys.zig's; this
+ // one seeds held selections in two panes, which only internals reach.
test "jump selection clears source and destination state across panes" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
@@ -947,7 +880,9 @@ const TagNameTintTests = struct {
return visible_name;
}
- test "tag filename tint excludes directories dirty marker and output commands" {
+ // A file pane's is test/behaviour/tags.zig's; a search pane's needs
+ // results put in through fillResults.
+ test "tag filename tint of a search pane excludes its directory and command" {
for ([_]bool{ false, true }) |bottom| {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 24 });
defer p.deinit();
@@ -959,7 +894,6 @@ const TagNameTintTests = struct {
configure(p);
defer p.custom_theme = null;
p.settings.tag_bottom = bottom;
- try std.testing.expect((try check(p, 0, pane.file.?.path)) > 0);
try panes.Output.fillResults(p, 0, "/project", .search, "tint", try p.gpa.dupe(u8, "no matches\n"), null);
const id = pane.search_pane.?;
p.update(.tick);