diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 19:27:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 19:36:04 -0300 |
| commit | 06c9201b3bea985a8d9658a9a95f09b11cb00535 (patch) | |
| tree | b226900cf3f9025f1ccadae970b886a4969cd498 /test/behaviour | |
| parent | ab9fa40a7bbbbb2e5589335f701f26ca225f9479 (diff) | |
| download | pardes-06c9201b3bea985a8d9658a9a95f09b11cb00535.tar.gz pardes-06c9201b3bea985a8d9658a9a95f09b11cb00535.zip | |
lsp_client: SPC l a passes the server's own diagnostics that touch the caret back in the request's context, as the protocol has it (CodeActionContext.diagnostics), so a quick fix a server offers for a diagnostic alone comes (VIDEO2's B8, agent V5: on clangd's error at V8's src/torque/types.cc:163:53, `b.ToString()` with `b` a pointer, `SPC l a` answered `CodeAction: not found` even 5 s after landing, where Helix, LazyVim and Doom list `change '.' to '->'` first); THE CAUSE: the codeAction request sent `"context":{"diagnostics":[]}` (dev/lsp/lsp_client.zig:1078), and clangd offers its fix-its only for the diagnostics a client passes back; THE FIX: the request carries, as the server gave them, the diagnostics whose range holds the caret (start <= caret <= end, the server's columns on both sides), read as `]d` reads them: pulled when the server pulls (LSP 3.17), else its last publish, waited for up to diag_ms when a didChange postdates it; that read is one function now (diagnosticsOf, the old `diagnostics` and renderStore's per-file branch folded into it; its values own their strings, the store's copy may go while the mutex is let go); a pulling server costs one textDocument/diagnostic round trip more per SPC l a; no core, dump, digest, frame or hot path touched (a language server's worker); RUN (TEST FIRST): test/lspmock.zig gains LSPMOCK_MODE=push (clangd's way: no diagnosticProvider, one error published at each didOpen and didChange) and offers `change '.' to '->'` first for each diagnostic passed back; behaviour/language_servers.zig "SPC l a passes back the server's own diagnostics at the caret ..." makes the mock C's server in that mode, opens main.c at the `.` of `return b.n;`, and asks `▶ 1 change '.' to '->'` and its digit giving `b->n`: fails on ab9fa40a7bbb (`not on the screen: ▶ 1 change '.' to '->'`, the rows the mock's three), passes now; the existing SPC l a test (a pulling server, the caret off its diagnostic) lists the same three rows; a user hit it on every clangd fix-it (and any server whose quick fixes hang on a diagnostic: rust-analyzer's, gopls's); the real check (clangd 23.1.5, this tree's Debug tui in a private session, .scratch/walkui/CA/demo): see CA's report; GATES (Debug tui): behaviour-test language-servers 14/14, the whole 290/290 (+1), core-test 1172/1347 (175 skipped, as on the base); load 2.5 to 12.4
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/language_servers.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/behaviour/language_servers.zig b/test/behaviour/language_servers.zig index d1b160ee..7f1eef73 100644 --- a/test/behaviour/language_servers.zig +++ b/test/behaviour/language_servers.zig @@ -324,6 +324,28 @@ test "language-servers: SPC l a lists the server's code actions in the pane's ta try s.expect(body, before); } +test "language-servers: SPC l a passes back the server's own diagnostics at the caret, as the protocol has it, so a quick fix the server offers for one alone (clangd's `change '.' to '->'`) is listed, first, and its digit applies it" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var s = try Session.initLanguage(std.testing.allocator); + defer s.deinit(); + // C's server the scripted one, as clangd is: its diagnostics pushed, + // never pulled. + _ = setenv("LSPMOCK_MODE", "push", 1); + defer _ = setenv("LSPMOCK_MODE", "", 1); + _ = setenv("PARDES_LSP_C", std.c.getenv("PARDES_LSP_RS").?, 1); + defer _ = setenv("PARDES_LSP_C", "", 1); + const before = "int f(struct s *b) {\n return b.n;\n}\n"; + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "main.c", .data = before }); + var buf: [4096]u8 = undefined; + const main = try s.lookFile(s.at("{s}/main.c:2:13", .{buf[0..try tmp.dir.realPath(std.testing.io, &buf)]})); + try s.keys(" la"); + _ = try s.where("▶ 1 change '.' to '->'"); + _ = try s.where(" 2 mock action: extract"); + try s.keys("1"); + try s.expect(s.at("/pane/{d}/body", .{main}), "int f(struct s *b) {\n return b->n;\n}\n"); +} + 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(); |
