Skip empty find match at the end of previous match (Part 2 for issue #116445) #116821
+7
−4
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.
This PR is related to #116445
JS engine will provide empty string matches at the end of non-empty matches if RegExp has zero or more quantifier (
*
)While currently VS Code provides same results as JS (which is expected), these empty matches do not provide any useful value and may be confusing to users (see linked issue).
Moreover it's hard to observe these matches - Alt+Enter will select all ranges, but because cursors at the end of these empty ranges overlap with end of previous selections they are basically ignored.
Moreover actions triggered on Previous/Next match will intentionally skip this kind of matches which leads to strange values for current selection index during navigation "1 of 9", "3 of 9", "4 of 9", "6 of 9" etc.
vscode/src/vs/editor/contrib/find/findModel.ts
Line 429 in 6c12d9f
This change updates search model in a way that won't produce empty ranges at the end of previous matches. Empty matches that are not overlap with non-empty matches are preserved as previously.
@rebornix would love to hear your feedback about this proposal.
P.S. This is second part of the fix for #116445 which provides improvement for match behavior.
Part 1 for navigation fix (do not skip non-empty matches in same line) submitted as draft as well - #116823