-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(tags): search for @name inside of tags
#14853
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
base: master
Are you sure you want to change the base?
Conversation
the-mikedavis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking for a @name capture in a match of a @definition.* capture is correct (we should aim to follow https://tree-sitter.github.io/tree-sitter/4-code-navigation.html). The range of the symbol should be the entire @definition.* capture though. Ideally the tags.scm query should capture the entire definition with @definition.* and the @name should be used for display purposes, for example in the picker.
helix-term/src/commands/syntax.rs
Outdated
| let start = text.byte_to_char(mat.node.start_byte() as usize); | ||
| let end = text.byte_to_char(mat.node.end_byte() as usize); | ||
|
|
||
| let mut inner_iter = syntax.tags(text, loader, mat.node.byte_range()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should never need to invoke a new query within a match of that same query. That's working around tags iterator returned captured nodes rather than entire matches. This probably needs work in tree-house to add an iterator over matches rather than captures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i expected as much. not quite sure where to start in tree-house, but i'll see what i can come up with ...
|
updated the implementation here to use helix-editor/tree-house#29 and converted to draft, while depending on my git branch for the tree-house dependency. |
a467758 to
28cdd41
Compare
@name inside of tags@name inside of tags
28cdd41 to
782b099
Compare
i noticed this while trying to improve the go and rust tags and noticed, that the go tags had some
@namequeries, that didn't seem to do anything, while the rust did not. when querying for the go syntax the picker showed the whole definition: (or at least the first line of it), while the rust picker (correctly) only displayed the name.screenshots
the go lsp only shows the name:

while the rust syntax picker showed the correct name, when selecting a symbol, only selected the name of the definition is selected, while the lsp symbol picker selects the entire definition.
screenshots
(after selecting the `Thing` struct in the picker):this pr fixes that by just trying to find a
@namein thedefinitioncapture and falling back to displaying whole match if none is found. i am not quite sure with my implementatiowith this pr i can also update the rust tags, so that the syntax query matches the whole definition, which i did in the second commit.
additional notes: the currently ignored
@namecaptures are already used by quite a few grammars, includinggo,ts/js,python,c#andelispto name a few.