Skip to content

Commit e7a4442

Browse files
committed
fix: don't allow empty scope
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
1 parent 3af6493 commit e7a4442

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lua/ibl/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ M.refresh = function(bufnr)
244244
local scope_row_start, scope_col_start, scope_row_end, scope_col_end = -1, -1, -1, -1
245245
local scope_index = -1
246246
if scope then
247+
---@diagnostic disable-next-line: cast-local-type
247248
scope_row_start, scope_col_start, scope_row_end, scope_col_end = scope:range()
248249
scope_row_start, scope_col_start, scope_row_end = scope_row_start + 1, scope_col_start + 1, scope_row_end + 1
249250
end

lua/ibl/scope.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ M.get = function(bufnr, config)
7272
local include_node_types =
7373
utils.tbl_join(config.scope.include.node_type["*"] or {}, config.scope.include.node_type[lang] or {})
7474

75-
while node do
75+
while node and node:byte_length() > 0 do
7676
local type = node:type()
7777

7878
if

0 commit comments

Comments
 (0)