diff options
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/language_servers.zig | 25 | ||||
| -rw-r--r-- | test/behaviour/look_and_exec.zig | 23 | ||||
| -rw-r--r-- | test/behaviour/other_files.zig | 16 |
3 files changed, 64 insertions, 0 deletions
diff --git a/test/behaviour/language_servers.zig b/test/behaviour/language_servers.zig index 904fcfba..13e42fa6 100644 --- a/test/behaviour/language_servers.zig +++ b/test/behaviour/language_servers.zig @@ -298,3 +298,28 @@ test "language-servers: Index runs the language's indexer at the project's root, const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; try std.testing.expect(std.mem.startsWith(u8, try bodyOf(&s, dir), s.at("% cd '{s}' && rust-analyzer scip .", .{dir}))); } + +test "language-servers: SPC l a lists the server's code actions in the pane's tag by their digits, the one under the cursor shown as its edit, and its digit applies it, one the server left to resolve resolved first" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var s = try Session.initLanguage(std.testing.allocator); + defer s.deinit(); + const before = "mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n"; + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "main.rs", .data = before }); + var buf: [4096]u8 = undefined; + const main = try s.lookFile(s.at("{s}/main.rs:4:13", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]})); + const body = s.at("/pane/{d}/body", .{main}); + try s.keys(" la"); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), "+Lsp") == null); + _ = try s.where("▶ 1 mock action: extract"); + _ = try s.where(" 2 mock action: add a line"); + _ = try s.where(" 3 mock action: rename add to sum"); + // The third, its edit asked for with codeAction/resolve: the two calls. + try s.keys("\u{F800}\u{F800}"); + _ = try s.where("let x = sum(1, 2);"); + try s.expect(body, before); + try s.keys("3"); + try s.expect(body, "mod lib;\n\nfn main() {\n let x = sum(1, 2);\n let y = sum(3, 4);\n let _ = x + y;\n}\n"); + try s.keys("u"); + try s.expect(body, before); +} diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig index a7de93cd..251b6325 100644 --- a/test/behaviour/look_and_exec.zig +++ b/test/behaviour/look_and_exec.zig @@ -790,3 +790,26 @@ test "look-and-exec: a look at a directory opens a pane listing it, as acme's di try std.testing.expectEqualStrings("later", again[1]); try std.testing.expectEqualStrings("sub/", again[2]); } + +test "look-and-exec: a reading pane that walks to another file is the same pane: its number, an open of its files reading the new text, /log's rename for it, the file it left in Recent" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "a\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = "b\n" }); + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + var buf: [4096]u8 = undefined; + const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)]; + const r = try s.lookFile(s.at("{s}/a.txt", .{dir})); + const body = try s.hold(s.at("/pane/{d}/body", .{r}), 0); + // A step in place: b.txt in the pane a.txt was in. + try s.write(s.at("/pane/{d}/look", .{r}), s.at("{s}/b.txt\n", .{dir})); + try expectEqual(r, try s.focused()); + try s.expect(s.at("/pane/{d}/name", .{r}), s.at("{s}/b.txt\n", .{dir})); + try std.testing.expectEqualStrings("b\n", try s.readFid(body)); + s.clunk(body); + const log = try s.read("/log"); + try std.testing.expect(std.mem.endsWith(u8, log, s.at("rename {d} {s}/b.txt\n", .{ r, dir }))); + try std.testing.expect(std.mem.indexOf(u8, log, s.at("del {d} ", .{r})) == null); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/recent"), s.at("{s}/a.txt", .{dir})) != null); +} diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig index b19ffa0f..e6c104c3 100644 --- a/test/behaviour/other_files.zig +++ b/test/behaviour/other_files.zig @@ -22,6 +22,22 @@ test "other-files: kbdin types at the pane with the keyboard and mousein clicks, try std.testing.expectError(error.Refused, s.read("/kbdin")); } +test "other-files: kbdin's keys are the user's: SPC f f opens Find's picker in the pane's tag where jumps walk, not the +Search a script's Find opens" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "a\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = "b\n" }); + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + var buf: [4096]u8 = undefined; + _ = try s.lookFile(s.at("{s}/a.txt", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]})); + try s.keys(" ff"); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), "+Search") == null); + // Its rows under the tag of the pane typed at, the cursor on the first. + _ = try s.where("▶ a.txt"); + _ = try s.where(" b.txt"); +} + test "other-files: kbdin's Kalt rune is Alt on the key after it alone, and an Alt key types nothing" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); |
