-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: reverse iteration through node parents #3214
Conversation
I wasn't able to add any tests because the
|
Possible follow-up: expose this in the query syntax via an "anti-anchor"
so downstream doesn't need custom predicates like |
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.
Could you add a test for this function in node_test.rs
?
run |
Currently, to iterate over all parents of a given node, one would need to repeatedly call
ts_node_parent()
on the node itself and on each of its parents.This creates performance issues for deep trees (neovim/neovim#24965), as
ts_node_parent()
itself has to iterate over all the node's parents (in reverse order, from root to the node) to find the last one.To address this performance issue, we can introduce a function that allows iterating over the node's parents in reverse order.