Skip to content

Commit f82c51a

Browse files
committed
chore(extract_block): add nil check for first/last child
1 parent 5268cc6 commit f82c51a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lua/refactoring/refactor/106.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,13 @@ local function extract_block_setup(refactor)
331331
local block_first_child = function_body[1]
332332
local block_last_child = function_body[#function_body]
333333

334+
if not block_first_child then
335+
return false, "block_first_child is nil"
336+
end
337+
if not block_last_child then
338+
return false, "block_last_child is nil"
339+
end
340+
334341
local first_line_region = Region:from_node(block_first_child)
335342
local last_line_region = Region:from_node(block_last_child)
336343

0 commit comments

Comments
 (0)