Fix wrong matches in multiline file search#160665
Merged
roblourens merged 2 commits intomicrosoft:mainfrom Sep 21, 2022
bvschaik:bugfix/multiline-search
Merged
Fix wrong matches in multiline file search#160665roblourens merged 2 commits intomicrosoft:mainfrom bvschaik:bugfix/multiline-search
roblourens merged 2 commits intomicrosoft:mainfrom
bvschaik:bugfix/multiline-search
Conversation
roblourens
reviewed
Sep 12, 2022
Member
roblourens
left a comment
There was a problem hiding this comment.
This looks great, thanks for investigating this. re: your comment about tests, I agree that we should add a test, and I do see tests for the class in ripgrepTextSearchEngineUtils.test.ts. This is testing the whole parser end to end, I think you should be able to construct the right input and test that it gets parsed correctly.
Contributor
Author
|
Thanks for the pointer, I totally overlooked those tests. I have added two tests:
|
When multiple consecutive lines match a regular expression, RipGrep will return them as one match with multiple submatches. The parser that converts the absolute positions of the submatches to (line number, column number) pairs was not taking into account that `inBetweenChars` may contain newlines, leading to wrong matches, and search/replace actions that gave unexpected results. Fixes #131507
andreamah
approved these changes
Sep 21, 2022
Contributor
andreamah
left a comment
There was a problem hiding this comment.
Thanks for the contribution 🙂
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When multiple consecutive lines match a regular expression, RipGrep will return them as one match with multiple submatches. The parser that converts the absolute positions of the submatches to (line number, column number) pairs was not taking into account that
inBetweenCharsmay contain newlines, leading to wrong matches, and search/replace actions that gave unexpected results.Fixes #131507