Skip to content

Commit e6c735b

Browse files
authored
fix: prevent index out of bounds in get_code_block_range (#271)
Add bounds checking to prevent nil indexing when row parameter is outsidethe valid range (less than 1 or greater than number of lines). Error: attempt to index local 'line' (a nil value)
1 parent 8c9930c commit e6c735b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lua/blink/cmp/windows/lib/docs.lua

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ end
154154
--- @param row number
155155
--- @return number?, number?
156156
function docs.get_code_block_range(lines, row)
157+
if row < 1 or row > #lines then return end
157158
-- get the start of the code block
158159
local code_block_start = nil
159160
for i = 1, row do

0 commit comments

Comments
 (0)