Skip to content

Commit

Permalink
fix: iterate over all nodes (#85)
Browse files Browse the repository at this point in the history
`Query:iter_matches` returns a TSNode[] iterator, but it was previously
being treated a single TSNode.

fixes #85
  • Loading branch information
b0o authored and theHamsta committed Sep 10, 2024
1 parent 9578276 commit 22c0299
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lua/nvim-dap-virtual-text/virtual_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@ function M.set_virtual_text(stackframe, options)
local query = get_query(ltree:lang(), 'locals')
if query then
for _, match, _ in query:iter_matches(tree:root(), buf, 0, -1) do
for id, node in pairs(match) do
local cap_id = query.captures[id]
if cap_id:find('scope', 1, true) then
table.insert(scope_nodes, node)
elseif cap_id:find('definition', 1, true) then
table.insert(definition_nodes, node)
elseif options.all_references and cap_id:find('reference', 1, true) then
table.insert(definition_nodes, node)
for id, nodes in pairs(match) do
for _, node in pairs(nodes) do
local cap_id = query.captures[id]
if cap_id:find('scope', 1, true) then
table.insert(scope_nodes, node)
elseif cap_id:find('definition', 1, true) then
table.insert(definition_nodes, node)
elseif options.all_references and cap_id:find('reference', 1, true) then
table.insert(definition_nodes, node)
end
end
end
end
Expand Down

0 comments on commit 22c0299

Please sign in to comment.