Fix Match Whole Word skipping overlapping matches#326447
Open
dobbydobap wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes whole-word search skipping overlapping candidates after a boundary-check failure.
Changes:
- Advances rejected matches by one Unicode code point.
- Adds regression coverage for issue #291591.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/vs/editor/common/model/textModelSearch.ts |
Adjusts search progression after rejected matches. |
src/vs/editor/test/common/model/textModelSearch.test.ts |
Adds overlapping-match regression test. |
Comment on lines
+551
to
+552
| // Not a whole-word match; advance one code point so overlapping whole-word matches aren't skipped. | ||
| this._searchRegex.lastIndex = matchStartIndex + (strings.getNextCodePoint(text, textLength, matchStartIndex) > 0xFFFF ? 2 : 1); |
| } | ||
|
|
||
| // Not a whole-word match; advance one code point so overlapping whole-word matches aren't skipped. | ||
| this._searchRegex.lastIndex = matchStartIndex + (strings.getNextCodePoint(text, textLength, matchStartIndex) > 0xFFFF ? 2 : 1); |
Contributor
Author
There was a problem hiding this comment.
Both good catches, thanks. Fixed the case-sensitive simpleSearch path (_findMatchesInLine now advances one position instead of the full match length on a rejected whole-word candidate), and reset _prevMatchStartIndex/_prevMatchLength after the explicit advance so the end-of-line guard stays reserved for returned matches. Extended the regression test to cover the case-sensitive path and the aa-aa|aa in xaa-aa end-of-line case
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 #291591. Match Whole Word is applied as a post-filter on each regex match; when a candidate fails the boundary check, the search resumed at the end of that candidate, skipping any valid whole-word match that starts inside it (e.g. the trailing
aa-aainxaa-aa-aa, whichgrep -wfinds). Now it advances one code point on a failed check so overlapping matches are considered. Added a regression test.