-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[LSP] textDocument/didChange
handler behavior doesn't follow lsp spec
#70392
Comments
That does seem like a problem. We should check with @kayle to make sure that VS LSP client is following the spec here as well before changing anything |
Thanks @CyrusNajmabadi, just to give you a little bit more context, this is causing issues when trying to use an lsp client other than vscode's, for example neovim. |
I took a quick look at the VS LSP client, and from what I can tell it follows the spec. Note in particular that if you make several edits to a document in a single edit, the didChange notification may represent those edits differently as long as the logical resulting text is the same. Roslyn certainly should not reorder the changes in a didChange notification since that could change the resulting text. |
@kayle what exactly do you mean here? The LSP spec states that if a Roslyn computes the text positions where these edits should be applied using the same text state for every edit in the For example, consider a
Roslyn orders the changes in a For example, consider a |
@jmederosalvarado he means that the lsp changes you hear about may not correspond precisely to the ITextChanges in the actual snapshot. The vs text model is much more precise and fine-grained. To match the lsp spec it may have to do things like consolidate discontinuous changes into single changes. That's totally fine here, and we'll update our impl to match the spec. |
When handling
textDocument/didChange
with a list of changes, these are being applied to the document "at once" based on the previous document version, moreover, the implementation currently assumes that these changes are sorted. The current behavior matches this description. However the lsp spec for this clearly states that changes should be applied sequentially and each changeN
acts on the resulting state after applying change0...N-1
.The relevant code for the current behavior can be found here and here.
For example the following code should print
ahbello
where it should printabhello
:The text was updated successfully, but these errors were encountered: