Skip to content

Commit

Permalink
fix: don't allow empty scope
Browse files Browse the repository at this point in the history
There seems to be a bug in treesitter that allows an infinite loop of
node parents, if the node is empty.
IBL doesn't care about the node if it's empty anyway, so we can just
ignore them.

fix #930
  • Loading branch information
lukas-reineke committed Oct 7, 2024
1 parent 3af6493 commit e7a4442
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/ibl/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ M.refresh = function(bufnr)
local scope_row_start, scope_col_start, scope_row_end, scope_col_end = -1, -1, -1, -1
local scope_index = -1
if scope then
---@diagnostic disable-next-line: cast-local-type
scope_row_start, scope_col_start, scope_row_end, scope_col_end = scope:range()
scope_row_start, scope_col_start, scope_row_end = scope_row_start + 1, scope_col_start + 1, scope_row_end + 1
end
Expand Down
2 changes: 1 addition & 1 deletion lua/ibl/scope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ M.get = function(bufnr, config)
local include_node_types =
utils.tbl_join(config.scope.include.node_type["*"] or {}, config.scope.include.node_type[lang] or {})

while node do
while node and node:byte_length() > 0 do
local type = node:type()

if
Expand Down

0 comments on commit e7a4442

Please sign in to comment.