microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.48k stars 325 forks source link

Language client requests diagnostics illogically #1584

Open robotman2412 opened 2 weeks ago

robotman2412 commented 2 weeks ago

I've created a language server and an extension counterpart that uses this library (v9.0.1) as the language client. The language server works fine but (at least with the example code) the language client requests diagnostics for the wrong file when opening files in the editor.

When I open one file, then open another (so two tabs now), the diagnostics for the first file are requested twice (as opposed to once for each file). I also can't figure out how to request diagnostics again when saving a file.

Now this would be an issue I could work around if I knew how to explicitly tell the language client to "go get diagnostics for that file" but I don't. I also can't find any obvious documentation other than the relatively surface-level tutorials from Microsoft.

Language server is asm.py from https://github.com/robotman2412/faerie-cpu Language client extension is https://github.com/robotman2412/vscode-faerieasm

Note: The language client looks for the language server as faerie-as by default, which I've symlinked (~/.local/bin/faerie-as -> asm.py) locally. You can either do the same, or open the extension settings and enter the full path to asm.py.

dbaeumer commented 2 weeks ago

@robotman2412 I tried to reproduce this in my testbed but I am unable to do so. Can you try to set a breakpoint in diagnostics.js in the vscode-languageclient npm module in pullAsync and see how often you hit this breakpoint. This is were the client ask the server for diagnostics.

I assume you are using pull diagnostics. Do you have inter file dependencies set to true?

robotman2412 commented 2 weeks ago

I have inter file deps set to true. I'm not sure how to call pull diagnostics, so no, I probably don't do that at the moment. I only initialize the language client, which does occasionally do requests on its own.

dbaeumer commented 2 weeks ago

That is pull diagnostics. The server specifies this via its capabilities. Is that what your server is doing?

robotman2412 commented 1 week ago

The server is capable of pull diagnostics. If it weren't (or not correctly) then I would never get any diagnostics. Instead, I get diagnostics requested for files I didn't expect (AKA not the file I just started editing), which the server immediately handles.

dbaeumer commented 1 week ago

If you have inter file dependencies set to true it will request diagnostics for files open in other tabs as well. This is done to ensure porper diagnostics in cases where changes in file A might fix or add new diagnostics in file B