diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 02:49:36 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 04:10:54 -0300 |
| commit | 8393c24f76675f182055149645c10af3102b739e (patch) | |
| tree | 3844cb4b77d4225d604e7ad18dbf6dfd64dc72de /test | |
| parent | 148e48dd9b8cd7e66aa1521daa49a64852b1650e (diff) | |
| download | pardes-8393c24f76675f182055149645c10af3102b739e.tar.gz pardes-8393c24f76675f182055149645c10af3102b739e.zip | |
lsp_client, Output, lspmock, syntax, Pick, Query, docs: the Symbols builtin (a language server's documentSymbol) gives the Symbols picker's marks and order (UX DESIGN N, binding: "The builtin `Symbols` keeps reading the server but gets the same mark, order and qualified names, from `SymbolKind`"): walkSymbols keeps each symbol's SymbolKind, mapped onto N2's kinds (5 Class, 10 Enum, 11 Interface, 23 Struct, 26 TypeParameter a type; 6 Method, 9 Constructor, 12 Function, 25 Operator a function; 7 Property, 8 Field, 22 EnumMember a field; 14 Constant a const; 13 Variable, 15 to 21 and 24 a var; 1 File to 4 Package a module; any other the other), and names each in the ones it is in (a DocumentSymbol's nesting, a SymbolInformation's `containerName`): a row is `shapes.rs:5:5-8 m Shape.side`, the rows types, functions, fields, then the rest, each in the server's order; the +Search keeps that order: a file's symbols are neither sorted by their places (Output.sortResults) nor laid out as Locations, which put a file's rows in their lines' order (Output.usesLocationsConfig): a row each, as the picker lists them; the walk's list picker (`Jumps walk`, Ask's) takes them in that order (tty `lsp` with zls: `f helper`, `f main`, `c std`, was `std`, `helper`, `main`); an index's Symbols (SCIP, dev/lsp/Scip.zig) keep their rows unmarked, one row each now too; the mock answers documentSymbol with a nested list in no kind's order (a const, a function, a struct with a field and a method, an enum with a member, a module); docs/typ guide's `Symbols name` and the reference's Symbols say the marks and the order; and three faults of the change before's rows, which its pictures showed (each TEST FIRST: the syntax.zig and Pick.zig tests failed with them first; the pattern guard came with its JavaScript case, not before it): a test whose name is longer than 200 bytes was no symbol, so its body was no scope and its local structs and functions were listed as types and functions (Pick.zig's own tests: `t typeIn = struct`): a name that long is cut, on a character, and a test's body lists nothing (370 rows of core/Pick.zig to 247); a name field is taken whole when it is one line (C++'s `namespace v8::internal::torque` named `v8`, now whole; a value binding's must still be a name, never a pattern: `const { x, y } = a`, OCaml's `let () =`); the qualifier dimmed in a row ran to the name's last `.`, a test's sentence's (`(SPEC §6.3, §7.3)` dimmed most of it): it is the candidate's `base` now, the qualifier's length from the gather, which also gives the scorer its basename bonus on the name; core/root.zig's import of syntax.zig (the change before) says what it does: without it a -Dtest-filter run compiles none of syntax.zig's tests, while a whole run has them (core-test 1135/1308 with it or without it; the change before said they ran nowhere: wrong); RUN (TEST FIRST): test/behaviour/language_servers.zig "language-servers: a server's Symbols are the Symbols picker's rows ..." opens shapes.rs with no index (the server asked) and asks the +Search's rows in that order: with walkSymbols' marks alone they came in their lines' order (`c LIMIT`, `f main`, `t Shape`, ...: the sort and the Locations layout), passes now; the index's Symbols test asks one row each (`lib.rs:1:11-15 Shape`); test/snapshots/lsp.golden re-recorded: only its symbols snap's three rows (marked and grouped) and the preview landing on their first, `helper`'s line 3; GATES on this stack (the change before under it): core-test 1135/1308 (173 skipped; base 1127/1301 with the base's one failure, a CPU-time test under load: colors' "the whole ring resolves in 150 ms"), shell-test 1356/1359 (3 skipped), pane-test 183/184 (1 skipped), behaviour-test 281/281 and --replay 281/281, process-test 1 of 147 failed (tty editing: lsp, its golden: re-recorded, the ten `tty editing: lsp` cases 0 of 10 failed), term-test 17/17, kitty-test 45/45; the dump fuzz (Names.Cand.group, Stream.Batch.symbols) at 40,000 join seeds twice and 1,779 image seeds 13/13; the soak `replicas -- --clients 5 --rtt 30,80,207`: diverged 0, unequal 0, quiet checks 421/0 415/0 590/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak; the gui unit-test 1960/1964 (4 skipped; its one failure the perf check's BaselineHarnessMismatch, every base's); core-test, shell-test, pane-test and behaviour-test again after the three faults: the same counts; the pictures (the S kit at 26 px, neonotte84, 100x30, typed through the pty; .scratch/walkui/W6/png): today's install (install74) beside this tree's Debug gui, SPC s s on core/Pick.zig (today 127 rows of declarations, `pub fn deinit(...` first; here 247, `t Pick = @This()` first, the types, then the functions ...) and on V8's torque-parser.cc (today 132, here 273 under `v8::internal::torque.`), and `count` typed (today the cursor on `count`, then `paneCount` and every row whose signature holds c-o-u-n-t, `[]const u8` among them; here `f count` current, `f paneCount`, `c counts_zig`, then the tests whose sentences match); no frame or perf gate (the user's rule of 2026-11-26); load 3.0 to 14.2
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'test')
| -rw-r--r-- | test/behaviour/language_servers.zig | 25 | ||||
| -rw-r--r-- | test/lspmock.zig | 11 | ||||
| -rw-r--r-- | test/snapshots/lsp.golden | 12 |
3 files changed, 39 insertions, 9 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; + } +} diff --git a/test/lspmock.zig b/test/lspmock.zig index 0fd34677..6f52f568 100644 --- a/test/lspmock.zig +++ b/test/lspmock.zig @@ -257,8 +257,15 @@ fn handle(a: std.mem.Allocator, raw: []const u8) void { } else if (std.mem.eql(u8, method, "textDocument/hover")) { reply(a, rid, "{{\"contents\":{{\"kind\":\"markdown\",\"value\":\"mock hover: pub fn add\"}}}}", .{}); } else if (std.mem.eql(u8, method, "textDocument/documentSymbol")) { - reply(a, rid, "[{{\"name\":\"main\",\"kind\":12,\"range\":{s},\"selectionRange\":{s}}}]", .{ - range(a, 2, 0, 11), range(a, 2, 3, 7), + // Nested and in no kind's order: a const, a function, a struct + // with a field and a method, an enum with a member, a module. + reply(a, rid, "[{{\"name\":\"LIMIT\",\"kind\":14,\"range\":{s},\"selectionRange\":{s}}},{{\"name\":\"main\",\"kind\":12,\"range\":{s},\"selectionRange\":{s}}}," ++ + "{{\"name\":\"Shape\",\"kind\":23,\"range\":{s},\"selectionRange\":{s},\"children\":[{{\"name\":\"side\",\"kind\":8,\"range\":{s},\"selectionRange\":{s}}},{{\"name\":\"area\",\"kind\":6,\"range\":{s},\"selectionRange\":{s}}}]}}," ++ + "{{\"name\":\"Kind\",\"kind\":10,\"range\":{s},\"selectionRange\":{s},\"children\":[{{\"name\":\"Round\",\"kind\":22,\"range\":{s},\"selectionRange\":{s}}}]}},{{\"name\":\"lib\",\"kind\":2,\"range\":{s},\"selectionRange\":{s}}}]", .{ + range(a, 0, 0, 21), range(a, 0, 6, 11), range(a, 2, 0, 11), range(a, 2, 3, 7), + range(a, 3, 0, 18), range(a, 3, 11, 16), range(a, 4, 4, 14), range(a, 4, 4, 8), + range(a, 5, 4, 16), range(a, 5, 7, 11), range(a, 7, 0, 11), range(a, 7, 5, 9), + range(a, 8, 4, 10), range(a, 8, 4, 9), range(a, 10, 0, 8), range(a, 10, 4, 7), }); } else if (std.mem.eql(u8, method, "workspace/symbol")) { const q = str(get(params, "query")) orelse ""; diff --git a/test/snapshots/lsp.golden b/test/snapshots/lsp.golden index c680700d..0db3b21e 100644 --- a/test/snapshots/lsp.golden +++ b/test/snapshots/lsp.golden @@ -59,13 +59,13 @@ == snap symbols grid=120x41 cursor=24,2 |2: ^ a.zig:8 › ␣ l Symbols 1/3 |3: │ │ Walk Look Split Newcol Grep Edit Copy Keep Drop | Find Grep Recent Panes Symbols All Jumplist -|4: │ │ ▶ a.zig:1:7-9 std -|5: │ │ a.zig:3:4-9 helper -|6: │ │ a.zig:7:8-11 main +|4: │ │ ▶ a.zig:3:4-9 f helper +|5: │ │ a.zig:7:8-11 f main +|6: │ │ a.zig:1:7-9 c std |7: │ │ -|8: 1▸const std = @import("std"); +|8: 1 const std = @import("std"); |9: 2 -|10: 3 fn helper(x: u32) u32 { +|10: 3▸fn helper(x: u32) u32 { |11: fn helper(x: u32) u32 |12: (fn (u32) u32) |13: 4 return x + 1; @@ -81,6 +81,6 @@ |4: │ │ nothing matches |5: │ │ |6: │ │ -|8: 1 const std = @import("std"); +|10: 3 fn helper(x: u32) u32 { == snap nothing grid=120x41 cursor=29,2 |2: ^ a.zig:8 › ␣ l Symbols jngd 0 |
