summaryrefslogtreecommitdiff
path: root/test/behaviour/look_and_exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:22:33 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:31:56 -0300
commit8fe05231e6e683b09b89356d4dff0ddb487962e4 (patch)
tree6c5b34dca32f89488001ba0ef21588d34dc6b7d1 /test/behaviour/look_and_exec.zig
parent4d4d9fcba44798340184f865d119e49c63709b70 (diff)
downloadpardes-8fe05231e6e683b09b89356d4dff0ddb487962e4.tar.gz
pardes-8fe05231e6e683b09b89356d4dff0ddb487962e4.zip
test: twenty-one more of test/panes.zig's tests through the 9P tree alone: in test/behaviour/tags.zig a tag with a newline as tall as its lines, a tag with more lines than rows scrolling to its caret (a column tag one row), a click on a wrapped tag row and on a word the wrap breaks (SyntaxBold toggled, read from /ctl), and a name drafted in the tag (committed by Enter, dropped by two Escs or by leaving the pane or entering a header, edited by grapheme, an empty one and an oversized one not committed, a middle-clicked Save committing it first); in test/behaviour/keys.zig (guide.typ's Keys) a prompt's entry and cancellation (s, the four pipes, Save on a scratch) leaving tag, body and dot, a prompt opening over a full tag, generated output refusing the pipe prompts, a cancelled s or S restoring the selection, a counted paste of nothing and a count or prefix a click or a change of pane cancels (the next l moving one); in look_and_exec.zig a look replacing its pane's selection (address, range, text, a count typed before it gone) and one into another pane leaving the source's dot; each checked to fail against a break (tag rows always one, the tag not scrolled to its caret, wrapTag recording no soft breaks, Enter not committing a name, Save not committing it first, nameBuffer taking names over 4096 bytes, leaving a pane keeping its draft, backspace by byte, Esc not closing a prompt, startPrompt refusing a full tag, a pipe prompt on generated output, Esc not restoring an s preview's selection, an empty paste keeping its count, a click keeping the count, clearNavigationSelection keeping the count, a look dropping every pane's dot); the old tests' internal checks with no surface (a pixel shell's tag layer, prompt_for, the input's mode) are not carried over
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/look_and_exec.zig')
-rw-r--r--test/behaviour/look_and_exec.zig46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index 2ff4345b..ec26b74f 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -36,3 +36,49 @@ test "look-and-exec: a bare :N or :N:M look addresses the pane itself, from its
try s.write(s.at("/pane/{d}/event", .{n}), "ML0 0 0 2 :1\n");
try expectEqual(.{ @as(u32, 0), @as(u32, 6) }, try s.range(dot));
}
+
+test "look-and-exec: a look replaces the selection it was made from, for an address, a range and text found" {
+ var s = try Session.initFile(std.testing.allocator, "alpha\nbravo\ncharlie\nneedle\n");
+ defer s.deinit();
+ const n = try s.focused();
+ const dot = s.at("/pane/{d}/dot", .{n});
+ const look = s.at("/pane/{d}/look", .{n});
+ try s.write(dot, "0 5");
+ try s.write(look, "/test.txt:3:2\n");
+ try expectEqual(.{ @as(u32, 13), @as(u32, 13) }, try s.range(dot));
+ try s.write(dot, "0 5");
+ try s.write(look, "/test.txt:2:2-4\n");
+ try s.expect(s.at("/pane/{d}/sel", .{n}), "rav");
+ try s.write(s.at("/pane/{d}/name", .{n}), "/tmp/look-selection-source.txt");
+ try s.write(dot, "0 5");
+ // A count typed before it is gone after it.
+ try s.keys("5");
+ try s.write(look, "needle\n");
+ try s.expect(s.at("/pane/{d}/sel", .{n}), "needle");
+ try s.keys("l");
+ try expectEqual(.{ @as(u32, 26), @as(u32, 26) }, try s.range(dot));
+ try expectEqual(n, try s.focused());
+}
+
+test "look-and-exec: a look into another pane leaves the source's dot and replaces the destination's selection" {
+ var s = try Session.initFile(std.testing.allocator, "source\nlines\n");
+ defer s.deinit();
+ const source = try s.focused();
+ const dest = try s.newPane();
+ try s.write(s.at("/pane/{d}/name", .{dest}), "/look-destination.txt");
+ try s.write(s.at("/pane/{d}/body", .{dest}), "alpha\nbravo\ncharlie\n");
+ const dest_dot = s.at("/pane/{d}/dot", .{dest});
+ for ([_]bool{ false, true }) |range| {
+ try s.write("/focus", s.at("{d}", .{source}));
+ try s.write(s.at("/pane/{d}/dot", .{source}), "0 6");
+ try s.write(dest_dot, "0 5");
+ try s.write(s.at("/pane/{d}/look", .{source}), if (range) "/look-destination.txt:2:2-4\n" else "/look-destination.txt:3:2\n");
+ try expectEqual(dest, try s.focused());
+ // The source keeps its dot, as acme's look leaves it.
+ try s.expect(s.at("/pane/{d}/sel", .{source}), "source");
+ if (range)
+ try s.expect(s.at("/pane/{d}/sel", .{dest}), "rav")
+ else
+ try expectEqual(.{ @as(u32, 13), @as(u32, 13) }, try s.range(dest_dot));
+ }
+}