commit 1f551e068f728ff38bd7fdcfa3a6daf362bab9da
parent bc67cf3ccdf935a0e2974fbbe5557a3d24931c54
Author: Lewis Russell <lewis6991@gmail.com>
Date: Tue, 12 Sep 2023 15:26:57 +0100
fix(treesitter): fixup for InspectTree
Fixes #25120
Diffstat:
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua
@@ -101,16 +101,18 @@ 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_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)
+ for _, child in pairs(parser:children()) do
+ child: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)
+ end
local nodes = traverse(root, 0, parser:lang(), injections, {})