Repository navigation
input: Add InputState::add_selection for programmatic multi-cursor - #3403
Merged
Merged
Conversation
huacnlee
enabled auto-merge (squash)
October 8, 2026 03:08
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 editing exists internally (Alt-click, the AddCursorAbove/Below actions), but applications had no public API to place a cursor at an arbitrary byte range. That makes features like "select all occurrences" (VS Code's Cmd+Shift+L) or additive "select next occurrence" impossible to build on top of the editor.
This change adds a single public method,
InputBaseState::add_selection, the programmatic equivalent of Alt-clicking another cursor into the text.Behavior mirrors the existing internal paths:
set_selected_range.set_selected_rangeviamove_to.Public API
gpui-base
InputBaseState::add_selection(&mut self, range: Range<usize>, cx: &mut Context<Self>)— Addsrangeas an additional selection while keeping existing ones, enabling programmatic multi-cursor placement (e.g. select-all-occurrences).This PR is 100% AI-generated, reviewed and validated by the contributor:
cargo fmt --check,cargo clippy -p gpui-base --all-targets -- --deny warnings, and the input test suite (329 passed, including the newtest_add_selection) are all green.