Skip to content

Add action to select inside enclosing brackets - #59005

Merged
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
totrytakeoff:select-inside-enclosing-bracket
Jun 11, 2026
Merged

Add action to select inside enclosing brackets#59005
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
totrytakeoff:select-inside-enclosing-bracket

Conversation

@totrytakeoff

@totrytakeoff totrytakeoff commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add an editor action for selecting the contents of the innermost enclosing bracket pair
  • register the action without assigning a default key binding
  • cover cursor, selection, nested bracket, no-op, and multi-cursor cases

Tests

  • cargo fmt --check
  • cargo test -p editor test_select_inside_enclosing_bracket --lib
  • cargo test -p editor test_move_to_enclosing_bracket --lib

Release Notes:

  • N/A

@cla-bot

cla-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @totrytakeoff on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jun 10, 2026
@totrytakeoff

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 10, 2026
@cla-bot

cla-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@totrytakeoff
totrytakeoff force-pushed the select-inside-enclosing-bracket branch from 89c929a to 790f684 Compare June 10, 2026 08:37
@totrytakeoff
totrytakeoff force-pushed the select-inside-enclosing-bracket branch from 790f684 to bdd0607 Compare June 10, 2026 09:15
@ChristopherBiscardi ChristopherBiscardi added the area:editor Feedback for code editing, formatting, editor iterations, etc label Jun 11, 2026

@ChristopherBiscardi ChristopherBiscardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks!

@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue Jun 11, 2026
@ChristopherBiscardi ChristopherBiscardi self-assigned this Jun 11, 2026
Merged via the queue into zed-industries:main with commit df35a07 Jun 11, 2026
44 checks passed
pull Bot pushed a commit to jasonkneen/zed that referenced this pull request Jun 17, 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
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
## Summary
- add an editor action for selecting the contents of the innermost
enclosing bracket pair
- register the action without assigning a default key binding
- cover cursor, selection, nested bracket, no-op, and multi-cursor cases

## Tests
- cargo fmt --check
- cargo test -p editor test_select_inside_enclosing_bracket --lib
- cargo test -p editor test_move_to_enclosing_bracket --lib

Release Notes:

- Added action to select the contents enclosed by brackets
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
## Summary
- add an editor action for selecting the contents of the innermost
enclosing bracket pair
- register the action without assigning a default key binding
- cover cursor, selection, nested bracket, no-op, and multi-cursor cases

## Tests
- cargo fmt --check
- cargo test -p editor test_select_inside_enclosing_bracket --lib
- cargo test -p editor test_move_to_enclosing_bracket --lib

Release Notes:

- Added action to select the contents enclosed by brackets
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

area:editor Feedback for code editing, formatting, editor iterations, etc cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants