From 07080f67fe7e526576d5d50777fb122a99b3e183 Mon Sep 17 00:00:00 2001 From: L Lllvvuu Date: Sat, 16 Sep 2023 02:48:49 -0700 Subject: perf(treesitter): do not scan past given line for predicate match Problem --- If a highlighter query returns a significant number of predicate non-matches, the highlighter will scan well past the end of the window. Solution --- In the iterator returned from `iter_captures`, accept an optional parameter `end_line`. If no parameter provided, the behavior is unchanged, hence this is a non-invasive tweak. Fixes: #25113 nvim-treesitter/nvim-treesitter#5057 --- runtime/doc/treesitter.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 64b4ca7ca2..ee34c45cce 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -976,8 +976,8 @@ Query:iter_captures({node}, {source}, {start}, {stop}) • {stop} (integer) Stopping line for the search (end-exclusive) Return: ~ - (fun(): integer, TSNode, TSMetadata): capture id, capture node, - metadata + (fun(end_line: integer|nil): integer, TSNode, TSMetadata): capture id, + capture node, metadata *Query:iter_matches()* Query:iter_matches({node}, {source}, {start}, {stop}, {opts}) -- cgit