summaryrefslogtreecommitdiff
path: root/test/behaviour/keys.zig
diff options
context:
space:
mode:
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");
+}