Fix multi-cursor selection with regex find mode and add tests #281827
+311
−14
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.
Description:
This PR addresses a bug where “Add selection to next find match” (Ctrl+D) did not work when regex find mode was enabled. It also adds automated tests to verify correct behavior in both regex and plain text search modes.
Context / Issue:
When using regex search in VSCode, adding a selection to the next find match failed (#5715). Users expect multi-cursor selections to work consistently whether regex is enabled or not.
Changes / Fix:
- MultiCursorSession updates:
- Fixed logic in addSelectionToNextFindMatch and addSelectionToPreviousFindMatch to properly handle regex search text.
- Ensured “add all matches to selection” works correctly with regex.
- Tests:
- Added multicursor.mock.test.ts covering:
- Adding selection to next match in regex mode.
- Adding selection to previous match in regex mode.
- Adding all matches to selection in regex mode.
- Documentation / Instructions:
- Instructions for running tests included.
Steps to Verify Fix:
npm run test-mockExample Test:
Notes:
Related Issue: (#107090)