Skip to content

Commit edf1790

Browse files
authored
Merge pull request nvim-treesitter#15 from theHamsta/fix-nil-reference
Fix: Add nil check to current_scope
2 parents c87b8ec + bbfa363 commit edf1790

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lua/nvim-treesitter-refactor/highlight_current_scope.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ function M.highlight_current_scope(bufnr)
1515
local node_at_point = ts_utils.get_node_at_cursor()
1616
local current_scope = locals.containing_scope(node_at_point, bufnr)
1717

18-
local start_line = current_scope:start()
18+
if current_scope then
19+
local start_line = current_scope:start()
1920

20-
if current_scope and start_line ~= 0 then
21-
ts_utils.highlight_node(current_scope, bufnr, current_scope_namespace, 'TSCurrentScope')
21+
if start_line ~= 0 then
22+
ts_utils.highlight_node(current_scope, bufnr, current_scope_namespace, 'TSCurrentScope')
23+
end
2224
end
2325
end
2426

0 commit comments

Comments
 (0)