This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
fix(rome_analyze): prevent the range end search of find_diff_range from crossing the start of the range #2697
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.
Summary
In #2694 I implemented a simplified solution (clamping the resulting range) to prevent the end of the diff range from crossing the start of the range when calculating the diff of a token removal operation. Unfortunately this solution isn't entirely correct and can result in mismatches between the two ranges (due to the clamping being applied to the new range independently from the original range)
With this PR I implemented a fix that completely removes the root cause of the issue by preventing the search for the endpoint of the modified range from crossing the start of the range in the first place, eliminating the need for the clamping operation on the resulting index
Fixes #2696
Test Plan
I also fixed the
diff_range_remove
test case, it turns out I made a mistake when calculating the values the range returned byfind_diff_range
were supposed to have, which in turn led to implementing an incorrect fix