# Refactor editor's select inside/around delimiter actions \(\#59472\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/906b7e661237c7a79d79baadd3768b77b6f7d1e1)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 906b7e661237c7a79d79baadd3768b77b6f7d1e1

Requested commit: 906b7e661237c7a79d79baadd3768b77b6f7d1e1

Commit: 906b7e661237c7a79d79baadd3768b77b6f7d1e1

Tree: 54b1c2f8e1373a68810e5a5507b6ba9cd8f7d347

Author: Dino

Committer: GitHub

## Message

```
Refactor editor's select inside/around delimiter actions (#59472)

# Objective

Both https://github.com/zed-industries/zed/pull/59005 and
https://github.com/zed-industries/zed/pull/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
```

## Parents

- [f2fbe40b5daf106ffb34861bcc3580a35ac8cca4](https://git.cafe/gitcafe/zed/commit/f2fbe40b5daf106ffb34861bcc3580a35ac8cca4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/906b7e661237c7a79d79baadd3768b77b6f7d1e1?format=markdown)
