Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix edge-case in tree-sitter expand_selection selection command #2877

Merged

Conversation

Triton171
Copy link
Contributor

If a tree-sitter grammar outputs multiple nodes with the same range that contain each other (I noticed this with the LaTex grammar and the text and word nodes), the expand_selection command currently "gets stuck" at them. This happens because the descendant_for_byte_range function always returns the lowest of these nodes, so changing the selection to the range of its parent doesn't do anything.
I changed it, so that now it skips nodes with identical ranges.

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

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

Great catch! I was wondering why A-o was getting 'stuck' on some nodes, I thought it might've had something to do with named vs unnamed but this makes sense 👍

(One example of this:

%% f.erl
foo(Bar) ->
    Bar#{a => b}.

with a selection over a => b will get stuck on master).

@the-mikedavis the-mikedavis merged commit e1b1a5e into helix-editor:master Jun 25, 2022
@Triton171
Copy link
Contributor Author

Yeah, it wasn't a big deal but just irritating enough when it happened that I wanted to fix it. Thanks for the super quick review :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants