# Update Editor::select_larger_syntax_node \(\#36971\) · gitcafe/zed

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

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

Visibility: public

Requested revision: b2d7e34e80d8a7c06db7b399f7110b11cf097bc7

Requested commit: b2d7e34e80d8a7c06db7b399f7110b11cf097bc7

Commit: b2d7e34e80d8a7c06db7b399f7110b11cf097bc7

Tree: a4db2dc2fdcf6e2e3ee6bf486fca7bdbe6978903

Author: Paul Sadauskas

Committer: GitHub

## Message

```
Update Editor::select_larger_syntax_node (#36971)

When the cursor was sitting on a syntactically insignificant character,
like a `{` or `,`, this function was selecting only that character, when
what the user likely wanted was to select the next larger syntax node.

Those punctuation characters all seemed to be not "named", in
tree-sitter terminology, so I updated the function to walk up the node
tree until it found a node where `is_named()` is true.

Closes #4555 

Also, while writing the tests, the output of a failing test with the
wrong thing selected was harder to read than it needed to be.

It used to output a diff of ranges, like this:

<img width="217" height="111" alt="image"
src="https://github.com/user-attachments/assets/00de53a8-8776-47aa-8101-5a5b5bc3fa5e"
/>

I leveraged the existing `generate_marked_text` helper function and
updated the assertion to output a diff of the text with the selection
markers:

<img width="211" height="116" alt="image"
src="https://github.com/user-attachments/assets/53b2b882-2676-4c70-8718-e2e2ba6f254e"
/>

Happy to make that a separate PR, if needed.

Release Notes:

- Fixed Editor select_larger_syntax_node to be smart about punctuation.
```

## Parents

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

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