Replies: 3 comments 3 replies
-
I would have also expected that you would need to specify a node further nested in the tree to actually reduce the query overhead. I believe in Neovim we only limit the line range |
Beta Was this translation helpful? Give feedback.
1 reply
-
Setting a start byte and end byte (or start and end points) on the query cursor does limit the set of nodes traversed. The cursor only visits nodes if they intersect the given range, or if a partial match is currently in progress, and was started on a node that did intersect the range. |
Beta Was this translation helpful? Give feedback.
2 replies
-
I think this is fixed with #22309 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I found that
Query
doesn't have caches or states to reuse information between edits, and always traverses the full tree and takes a lot of time ints_query_cursor__advance
. (Also there's a bug making it slower)This is acceptable for one-pass queries like in
tree-sitter-highlight
CLI. But it causes performance issues more and more often when tree-sitter are integrated in editors likehelix
andnvim-treesitter
.Note that
{start,end}_{byte,point}
doesn't help here. It can only limit the result size rather than the search space, let alone this limit is only respected under some conditions. For a "non-local" query like(foo . bar . qux @hl)
or(foo (bar) (qux) @hl)
, iffoo
are at the beginning of the file (or spans almost the full file) whilequx
is at the end and in view-port, we have to check everything between to determine if the query matchesbar
, although they are not visible.I'd like to ask for incremental queries, which maintains the result of queries and supports
edit
in less thanO(full_tree_size)
time, just likeedit
/parse
forTSTree
. So we could get "the diff of query results" and patch the highlighting quickly. This seems computationally very hard and I'm not sure if this time-complexity goal is achievable. So I post here for discussion.Beta Was this translation helpful? Give feedback.
All reactions