fix(language-server): correctly calculate coalesced document change#240
Merged
johnsoncodehk merged 1 commit intovolarjs:masterfrom Oct 7, 2024
rchl:fix/document-sync
Merged
fix(language-server): correctly calculate coalesced document change#240johnsoncodehk merged 1 commit intovolarjs:masterfrom rchl:fix/document-sync
johnsoncodehk merged 1 commit intovolarjs:masterfrom
rchl:fix/document-sync
Conversation
Member
|
Your method is simpler, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes vuejs/language-tools#4909
calculateChangeRangewas incorrectly calculating combined change if the document update contained multiple changes. It calculated offset for each change using the original state of the document as a base while the offsets for the next change need to be calculated based on a document state with previous change applied.I'm guessing that vscode coalesced changes so generally there was just a single one and the issue was never apparent there but with other editors there is no such guarantee.
To fix I've dropped the incorrect code and instead switched to converting changes to
ts.TextChangeRanges and using existingcombineChangeRangesutility function that seems to be doing the right thing.Calculating incorrect range for the snapshot resulted in incorrectly applying changes to the SFC, causing the generated document to end up with pretty much random content and causing random issues with different features.