mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(treesitter): fixup for InspectTree
Fixes #25120
(cherry picked from commit 040cba1faa
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
57aeacc344
commit
f0b1e46f91
@@ -102,16 +102,18 @@ function TSPlayground:new(bufnr, lang)
|
||||
-- the root in the child tree to the {injections} table.
|
||||
local root = parser:parse()[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, {})
|
||||
|
||||
|
Reference in New Issue
Block a user