Refactor editor's select inside/around delimiter actions - #59472
Conversation
Update the logic for both `SelectInsideDelimiters` and `SelectAroundDelimiters` to continue expanding to the next bracket pair on subsequent uses. This mirrors the behavior from `SelectInsideEnclosingBracket` so that we can eventually replace it with both of these actions.
The `SelectInsideEnclosingBracket` action is now replaced by both `SelectInsideDelimiters` and `SelectAroundDelimiters`. Since it never made it to a release, we're safe to just remove it without creating a deprecation warning or action alias.
|
Would it be possible to bind these actions to double-click? It's a nice-to-have from VSCode that I occasionally miss while working in Zed. Thanks! Video in action from vscode release notes: https://code.visualstudio.com/updates/v1_109#_select-bracket-and-string-content-with-double-click |
Unfortunately, I don’t believe we currently support letting users specify what happens on double or triple-click, and both of those are already in use, so we’d likely not want to change this behavior. I also believe that holding I suspect the only viable path would be to expose this through a setting, but we’d likely need a discussion first to understand whether there’s enough user interest :) |
…ies#59472) # Objective Both zed-industries#59005 and zed-industries#53789 introduced actions, at the editor context, which allow to select the content between brackets/delimiters, with the latter also adding an action to include the brackets/delimiters too. Shipping both would mean we end up with three distinct, but similar actions: * `editor: select inside enclosing bracket` * `editor: select inside delimiters` * `editor: select around delimiters` As such, in order to simplify this, the changes in this Pull Request remove the first action, while updating the logic for both `editor: select inside delimiters` and `editor: select around delimiters` in order to support continuous outwards expansion, like `editor: select inside enclosing bracket` supported. ## Solution * Remove `editor::SelectInsideEnclosingBracket` action, it's related method and tests * Updated `editor::selection::Editor::select_delimiters_impl` to use `MultiBufferSnapshot::enclosing_bracket_ranges` instead of `MultiBufferSnapshot::innermost_enclosing_bracket_ranges` so we can traverse all bracket ranges and expand to the next one ## Testing Besides manual testing, a new test case was added specifically for the selection expansion support, namely `editor::editor_tests::test_select_delimiters_expansion`. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - N/A
Objective
Both #59005 and #53789 introduced actions, at the editor context, which allow to select the content between brackets/delimiters, with the latter also adding an action to include the brackets/delimiters too.
Shipping both would mean we end up with three distinct, but similar actions:
editor: select inside enclosing bracketeditor: select inside delimiterseditor: select around delimitersAs such, in order to simplify this, the changes in this Pull Request remove the first action, while updating the logic for both
editor: select inside delimitersandeditor: select around delimitersin order to support continuous outwards expansion, likeeditor: select inside enclosing bracketsupported.Solution
editor::SelectInsideEnclosingBracketaction, it's related method and testseditor::selection::Editor::select_delimiters_implto useMultiBufferSnapshot::enclosing_bracket_rangesinstead ofMultiBufferSnapshot::innermost_enclosing_bracket_rangesso we can traverse all bracket ranges and expand to the next oneTesting
Besides manual testing, a new test case was added specifically for the selection expansion support, namely
editor::editor_tests::test_select_delimiters_expansion.Self-Review Checklist:
Release Notes: