-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completion request and content change arrival order #968
Comments
This sounds like a bug that should be investigated. There are many language servers that work with Visual Studio Code so it's hard for me to believe this is a bug that is affecting everyone (myself included as I am the author of a language server myself). How can this bug be reproduced? |
I can't believe it's a bug either because of its impact... This is for the Grain LSP I'm an author of. We moved up from a pretty old version of the client library to the latest as part of a major upgrade we are undertaking. In the Trace for our LSP we see this when we type a character at the start of a line for example: `[Trace - 7:46:01 AM] Sending request 'textDocument/completion - (99)'. [Trace - 7:46:01 AM] Sending notification 'textDocument/didChange'. and similarly for a completion character: `[Trace - 10:44:02 AM] Sending request 'textDocument/completion - (109)'. [Trace - 10:44:02 AM] Sending notification 'textDocument/didChange'. |
FWIW, I don't see this behaviour with Dart, I see the
However, my server is using incremental changes ( |
Interestingly, in the code for full (non-incremental) sync, there is some field called
Perhaps it's an optimisation to reduce traffic for full sync (so every keystroke isn't sending the entire document), but the completion request isn't forcing delivery? |
@DanTup is that on the latest version? We are doing full change, I'll look at incremental too. |
@marcusroberts yep, that was on v8 of the client. Although based on the code I linked above, I suspect the issue could be specific to full sync. |
Regarding the change delayer. The flushing of buffered full document syncs is happening here:
and at the corresponding place in |
I was actually able to reproduce this in full text document sync mode. Need to investigate why this is happening. |
The problem is that internally forceDocumentSync() is now async (send notification is async) and I need to await the force document sync. The reason this is not showing up in incremental sync is that there nothing is buffered. |
I'm glad you could reproduce and then find the cause, and so quickly too, thank you! |
…merald Fixes #968: Completion request and content change arrival order
Update to the latest release of vscode-languageclient, which includes microsoft/vscode-languageserver-node@529ee89 which fixes microsoft/vscode-languageserver-node#968: completion requests were sometimes sent before didChange requests, leading to broken/flaky completions
Watching the trace for communications between the extension and the server, we see textDocument/completion get sent before textDocument/didChange, so we are looking at the source code as it was before the change was made.
When it's a trigger character we can add it on to the text before the cursor (although the cursor position is reported in the changed source that follows in the didChange) but when it's just invoked by being an identifier that identifier isn't in the source we hold.
What's the best way to handle this? Our own server is single threaded so we know it will process them in this order, but I guess other servers are async and could be processing both at the same time? Is there a guaranteed order that all clients will send these two in?
The text was updated successfully, but these errors were encountered: