summaryrefslogtreecommitdiff
path: root/test/behaviour/look_and_exec.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour/look_and_exec.zig')
-rw-r--r--test/behaviour/look_and_exec.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig
index 3e6137b1..387c28a7 100644
--- a/test/behaviour/look_and_exec.zig
+++ b/test/behaviour/look_and_exec.zig
@@ -442,6 +442,27 @@ fn tmpPath(s: *Session, tmp: *std.testing.TmpDir) ![]const u8 {
return s.at("{s}", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]});
}
+test "look-and-exec: SPC : runs its line in a command pane at the project's root, the nearest directory at or above the pane's holding a .jj or a .git, where `:` runs it in the pane's own; its head `: root`" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.createDirPath(std.testing.io, ".git");
+ try tmp.dir.createDirPath(std.testing.io, "a/b");
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a/b/x.txt", .data = "x\n" });
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const root = try tmpPath(&s, &tmp);
+ _ = try s.lookFile(s.at("{s}/a/b/x.txt", .{root}));
+ try s.keys(":pwd\n");
+ const here = try paneNamed(&s, s.at("{s}/a/b", .{root}));
+ try std.testing.expect(std.mem.startsWith(u8, try s.read(s.at("/pane/{d}/body", .{here})), "% pwd\n"));
+ try s.keys(" :");
+ _ = try s.where(": root");
+ try s.keys("pwd\n");
+ const at_root = try paneNamed(&s, root);
+ try std.testing.expect(at_root != here);
+ try std.testing.expect(std.mem.startsWith(u8, try s.read(s.at("/pane/{d}/body", .{at_root})), "% pwd\n"));
+}
+
test "look-and-exec: a look opens spaced paths and locations without editing the source pane" {
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();