Skip to content

Commit

Permalink
fix: Traverse children langtrees manually
Browse files Browse the repository at this point in the history
  • Loading branch information
kwaszczuk committed Feb 14, 2024
1 parent 4171557 commit 02f27f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/treesitter-context/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,16 @@ local function get_parent_langtrees(bufnr, range)
local parent_langtrees = {root_tree}

while true do
child_langtree = parent_langtrees[#parent_langtrees]:language_for_range(range)
if child_langtree == parent_langtrees[#parent_langtrees] then
local child_langtree = nil

for _, langtree in pairs(parent_langtrees[#parent_langtrees]:children()) do
if langtree:contains(range) then
child_langtree = langtree
break
end
end

if child_langtree == nil then
break
end
parent_langtrees[#parent_langtrees + 1] = child_langtree
Expand Down

0 comments on commit 02f27f8

Please sign in to comment.