-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix replacement edit range computation (#12171)
## Summary This PR fixes various bugs for computing the replacement range between the original and modified source for the language server. 1. When finding the end offset of the source and modified range, we should apply `zip` on the reversed iterator. The bug was that it was reversing the already zipped iterator. The problem here is that the length of both slices aren't going to be the same unless the source wasn't modified at all. Refer to the [Rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=44f860d31bd26456f3586b6ab530c22f) where you can see this in action. 2. Skip the first line when computing the start offset because the first line start value will always be 0 and the default value of the source / modified range start is also 0. So, comparing 0 and 0 is not useful which means we can skip the first value. 3. While iterating in the reverse direction, we should only stop if the line start is strictly less than the source start i.e., we should use `<` instead of `<=`. fixes: #12128 ## Test Plan Add test cases where the text is being inserted, deleted, and replaced between the original and new source code, validate the replacement ranges.
- Loading branch information
1 parent
8210c1e
commit d870720
Showing
1 changed file
with
178 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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