Skip to content

Refactor editor's select inside/around delimiter actions - #59472

Merged
dinocosta merged 3 commits into
mainfrom
refactor/select-inside-brackets
Jun 17, 2026
Merged

Refactor editor's select inside/around delimiter actions#59472
dinocosta merged 3 commits into
mainfrom
refactor/select-inside-brackets

Conversation

@dinocosta

Copy link
Copy Markdown
Member

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 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:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • N/A

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.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 17, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 17, 2026
@dinocosta
dinocosta marked this pull request as ready for review June 17, 2026 10:25

@osiewicz osiewicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dinocosta
dinocosta enabled auto-merge June 17, 2026 10:35
@dinocosta
dinocosta added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit 906b7e6 Jun 17, 2026
43 checks passed
@dinocosta
dinocosta deleted the refactor/select-inside-brackets branch June 17, 2026 10:40
This was referenced Jun 18, 2026
@y1zhou

y1zhou commented Jun 25, 2026

Copy link
Copy Markdown

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

@dinocosta

Copy link
Copy Markdown
Member Author

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 ‎alt while clicking is already used for multi-cursors, so that’s probably not a valid option either.

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 :)

jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants