summaryrefslogtreecommitdiff
path: root/test/behaviour/keys.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 11:09:10 -0300
committerGabriel Schneider <[email protected]>2026-11-04 11:17:24 -0300
commita5504e6e808c5b147e114d43b5c165bbe714f3c3 (patch)
tree81d61c2d451a8715ca076088414be226dd49cb9a /test/behaviour/keys.zig
parentfa3031d6ded24d4ba7ab5bab21e17387e48306aa (diff)
downloadpardes-a5504e6e808c5b147e114d43b5c165bbe714f3c3.tar.gz
pardes-a5504e6e808c5b147e114d43b5c165bbe714f3c3.zip
test: test/output.zig's Mini, setting and command-output LookNext tests through the 9P tree alone: in a new test/behaviour/builtins.zig (docs/typ/builtins.typ) Mini mapping a file of the pane's directory over pardes's own of that name, one pane for it, a snapshot refreshed only by the next Mini, and Save on it writing nothing (the old test trimmed to the watch it never asks for, an effect); in test/behaviour/settings.zig every on/off setting the root ctl reads flipping when its word is written bare, and Theme and Shell taking a value (the old test trimmed to a window's fonts, transitions and passes in DumpConfig's report); in test/behaviour/keys.zig SPC j n in a command output (+Themes) selecting its whole row, Tab running it, and from a pane a Look took the keyboard to walking on in it, and SPC j n and SPC j p walking on and back from the place a Look's +Search listing chose (the old test trimmed to its fillResults answers); each checked to fail against a break (Mini making a new pane each time, a setting's bare word not flipping it, a command output's grain a word, the walk's owner forgotten)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/keys.zig')
-rw-r--r--test/behaviour/keys.zig49
1 files changed, 49 insertions, 0 deletions
diff --git a/test/behaviour/keys.zig b/test/behaviour/keys.zig
index 41a2821a..e659b369 100644
--- a/test/behaviour/keys.zig
+++ b/test/behaviour/keys.zig
@@ -225,3 +225,52 @@ test "keys: SPC j n and SPC j p walk Themes' rows, whole, never its section head
try s.keys("\t");
try std.testing.expectEqualStrings(names.items[brk - 1]["Theme ".len..], try setting(&s, "Theme"));
}
+
+test "keys: SPC j n in a command output selects its whole row, Tab runs it, and from where a Look took the keyboard it walks on there" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ for ([_][]const u8{ "a.txt", "b.txt" }) |name| try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = "x\n" });
+ var dir: [4096]u8 = undefined;
+ const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)];
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write("/look", s.at("{s}/a.txt\n", .{at}));
+ const a = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{a}), "Themes\n");
+ try s.keys(" jn");
+ const themes = try s.focused();
+ try std.testing.expect(themes != a);
+ const sel = s.at("/pane/{d}/sel", .{themes});
+ try s.expect(sel, "Theme orchard");
+ try s.keys(" jn\t");
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/ctl"), "\nTheme dusk\n") != null);
+ try s.write(s.at("/pane/{d}/exec", .{a}), "Look b.txt\n");
+ try std.testing.expect(try s.focused() != themes);
+ try s.keys(" jn");
+ try std.testing.expectEqual(themes, try s.focused());
+ try std.testing.expect(std.mem.startsWith(u8, try s.read(sel), "Theme "));
+}
+
+test "keys: SPC j n and SPC j p walk on from the place a Look's +Search listing chose, its keyboard left in the file" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "look-owner.txt", .data = "alpha target\nbeta target\ngamma target\n" });
+ var dir: [4096]u8 = undefined;
+ const at = dir[0..try tmp.dir.realPath(std.testing.io, &dir)];
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ try s.write("/ctl", "LookWord list\n"); // the +Search listing is what is walked
+ try s.write("/look", s.at("{s}/look-owner.txt\n", .{at}));
+ const file = try s.focused();
+ try s.write(s.at("/pane/{d}/exec", .{file}), "Look target\n");
+ try std.testing.expectEqual(file, try s.focused());
+ // The Look took the first; the walk goes on from it, and back.
+ try s.keys(" jn");
+ const results = try s.focused();
+ try std.testing.expect(results != file);
+ const sel = s.at("/pane/{d}/sel", .{results});
+ try s.expect(sel, "look-owner.txt:2:6-11");
+ try s.keys(" jp");
+ try std.testing.expectEqual(results, try s.focused());
+ try s.expect(sel, "look-owner.txt:1:7-12");
+}