diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-09-12 11:38:31 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2023-09-12 12:21:42 +0100 |
commit | 7a76fb8547548304450b59624f9c75a554396504 (patch) | |
tree | 572d0101d49919ecaa53c5bd20a63b5741daee64 /runtime/lua/vim/treesitter/dev.lua | |
parent | 1c4a93b591828bc6970edad6282c004eb46f0b2d (diff) | |
download | rneovim-7a76fb8547548304450b59624f9c75a554396504.tar.gz rneovim-7a76fb8547548304450b59624f9c75a554396504.tar.bz2 rneovim-7a76fb8547548304450b59624f9c75a554396504.zip |
fix(treesitter): remove more double recursion
Do not call `for_each_child` in functions that are already recursive.
Diffstat (limited to 'runtime/lua/vim/treesitter/dev.lua')
-rw-r--r-- | runtime/lua/vim/treesitter/dev.lua | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua index 72b6e3db4a..67aa8670ba 100644 --- a/runtime/lua/vim/treesitter/dev.lua +++ b/runtime/lua/vim/treesitter/dev.lua @@ -101,17 +101,15 @@ function TSTreeView:new(bufnr, lang) -- the root in the child tree to the {injections} table. local root = parser:parse(true)[1]:root() local injections = {} ---@type table<integer,table> - parser:for_each_child(function(child, lang_) - child:for_each_tree(function(tree) - local r = tree:root() - local node = root:named_descendant_for_range(r:range()) - if node then - injections[node:id()] = { - lang = lang_, - root = r, - } - end - end) + parser:for_each_tree(function(tree, ltree) + local r = tree:root() + local node = root:named_descendant_for_range(r:range()) + if node then + injections[node:id()] = { + lang = ltree:lang(), + root = r, + } + end end) local nodes = traverse(root, 0, parser:lang(), injections, {}) |