selectBetween: add multi-cursor support and Unicode flag#45
Open
GoodDingo wants to merge 2 commits intojohtela:masterfrom
Open
selectBetween: add multi-cursor support and Unicode flag#45GoodDingo wants to merge 2 commits intojohtela:masterfrom
GoodDingo wants to merge 2 commits intojohtela:masterfrom
Conversation
- Fix selectBetween to process each cursor independently when multiple cursors active
- Each cursor now searches within its own line scope, preserving all cursors
- Falls back to single-cursor mode when docScope=true for document-wide searches
- Add unicode flag to enable full Unicode regex support including property escapes (\p{L}, \p{Emoji}, etc.)
- Extract buildRegexFlags() helper function to centralize flag construction
Update CHANGELOG.md
Generated by npm dev
Author
|
Split to 2 commits (second is generated HTML, but there are some weird |
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.
Multi-cursor support for
modaledit.selectBetweenThis PR enhances the
modaledit.selectBetweencommand with two nice improvements:\p{L},\p{Emoji}, etc.Breaking Changes
None. Both new parameters are optional and default to backward-compatible values.
Example
With multi-cursor on, I can do
cifoperation that "does the right thing" and results inRationale...
Rationale
Multi-Cursor Support
Previously,
selectBetweenonly processed the primary cursor and discarded all other cursors, which was inconsistent with VS Code's multi-cursor philosophy and other ModalEdit commands. This limitation made the command unusable in multi-cursor workflows.Key design decisions:
docScopeis false)docScope: trueis used, falls back to single-cursor mode for predictable document-wide searcheshighlightMatches()(commands.ts:758-837)Unicode Flag
The standard JavaScript regex engine doesn't support Unicode property escapes by default. Without the
uflag, patterns like\p{L}(any Unicode letter) fail, making it impossible to properly handle:Implementation:
unicode: booleanparameter toSelectBetweenArgsinterfacebuildRegexFlags()helper (commands.ts:1057-1062)falsefor backward compatibilityExamples
Multi-Cursor Example
Select word at each cursor position across multiple lines:
{ "command": "modaledit.selectBetween", "args": { "from": "\\W", "to": "\\W", "regex": true } }With cursors on lines containing "hello world", "foo bar", and "test case", this will select "hello", "foo", and "test" simultaneously.
Unicode Example
Select Unicode words (any sequence of Unicode letters) using property escapes:
{ "command": "modaledit.selectBetween", "args": { "from": "[^\\\\p\\{L\\}_.:@#$%&*()+/!?-]", "to": "[^\\\\p\\{L\\}_.:@#$%&*()+/!?-]", "regex": true, "unicode": true } }This works correctly with international text like:
příliš-žluťoučký-kůň🎉 celebration 🎊hello世界мирWithout the
unicodeflag,\p{L}would be treated as literal characters and fail to match.