Skip to content

Commit

Permalink
fix(treesitter): attempt to call method 'type' (a nil value) (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
srghma authored Oct 23, 2024
1 parent 203c9f4 commit c96bb3b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lua/ufo/provider/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ function Treesitter.getFolds(bufnr)
error('UfoFallbackException')
end
for _, node in ipairs(matches) do
local start, _, stop, stop_col = node:range()
if stop_col == 0 then
stop = stop - 1
end
if stop > start then
local type = node.type and node:type() or nil
table.insert(ranges, foldingrange.new(start, stop, nil, nil, type))
if node.range then
local start, _, stop, stop_col = node:range()
if stop_col == 0 then
stop = stop - 1
end
if stop > start then
local type = node.type and node:type() or nil
table.insert(ranges, foldingrange.new(start, stop, nil, nil, type))
end
end
end
foldingrange.sortRanges(ranges)
Expand Down

0 comments on commit c96bb3b

Please sign in to comment.