summaryrefslogtreecommitdiff
path: root/test/behaviour
diff options
context:
space:
mode:
Diffstat (limited to 'test/behaviour')
-rw-r--r--test/behaviour/language_servers.zig25
1 files changed, 24 insertions, 1 deletions
diff --git a/test/behaviour/language_servers.zig b/test/behaviour/language_servers.zig
index 13e42fa6..80d1cb1e 100644
--- a/test/behaviour/language_servers.zig
+++ b/test/behaviour/language_servers.zig
@@ -206,7 +206,7 @@ test "language-servers: Symbols lists the file's definitions by name, a local's
try s.write(s.at("/pane/{d}/look", .{main}), s.at("{s}/lib.rs\n", .{std.fs.path.dirname(std.mem.trimEnd(u8, try s.read(s.at("/pane/{d}/name", .{main})), "\n")).?}));
try s.write(s.at("/pane/{d}/ctl", .{try s.focused()}), "Symbols\n");
const rows = try bodyOf(&s, "+Search");
- for ([_][]const u8{ "lib.rs:1:11-15\nShape\n", "lib.rs:2:8-11\narea\n", "lib.rs:5:8-10\nadd\n", "lib.rs:8:12-17\nSquare\n", "lib.rs:10:8-11\narea\n" }) |row|
+ for ([_][]const u8{ "lib.rs:1:11-15 Shape\n", "lib.rs:2:8-11 area\n", "lib.rs:5:8-10 add\n", "lib.rs:8:12-17 Square\n", "lib.rs:10:8-11 area\n" }) |row|
try std.testing.expect(has(rows, row));
try std.testing.expect(!has(rows, "lib.rs:5:12"));
}
@@ -323,3 +323,26 @@ test "language-servers: SPC l a lists the server's code actions in the pane's ta
try s.keys("u");
try s.expect(body, before);
}
+
+test "language-servers: a server's Symbols are the Symbols picker's rows: types, functions, fields, then the rest, each its kind's mark and its name in the ones it is in (UX DESIGN N)" {
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var s = try Session.initLanguage(std.testing.allocator);
+ defer s.deinit();
+ try s.write("/ctl", "Jumps new-pane\n");
+ // No index: the server is asked.
+ try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "shapes.rs", .data = "const LIMIT: u32 = 4;\n\nfn main() {}\npub struct Shape {\n side: u32,\n fn area() {}\n}\nenum Kind {\n Round,\n}\nmod lib;\n" });
+ var buf: [4096]u8 = undefined;
+ const dir = buf[0..try tmp.dir.realPath(std.testing.io, &buf)];
+ const shapes = try s.lookFile(s.at("{s}/shapes.rs:1:1", .{dir}));
+ try s.write(s.at("/pane/{d}/ctl", .{shapes}), "Symbols\n");
+ const rows = try bodyOf(&s, "+Search");
+ var at: usize = 0;
+ for ([_][]const u8{ "shapes.rs:4:12-16 t Shape\n", "shapes.rs:8:6-9 t Kind\n", "shapes.rs:3:4-7 f main\n", "shapes.rs:6:8-11 f Shape.area\n", "shapes.rs:5:5-8 m Shape.side\n", "shapes.rs:9:5-9 m Kind.Round\n", "shapes.rs:1:7-11 c LIMIT\n", "shapes.rs:11:5-7 n lib\n" }) |row| {
+ const found = std.mem.indexOfPos(u8, rows, at, row) orelse {
+ std.debug.print("{s} not after {d} in\n{s}\n", .{ row, at, rows });
+ return error.TestUnexpectedResult;
+ };
+ at = found + row.len;
+ }
+}