Skip to content

Commit

Permalink
fix: prevent index out of bounds in get_code_block_range (#271)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
zvrkSam authored Nov 5, 2024
1 parent 8c9930c commit e6c735b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lua/blink/cmp/windows/lib/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ end
--- @param row number
--- @return number?, number?
function docs.get_code_block_range(lines, row)
if row < 1 or row > #lines then return end
-- get the start of the code block
local code_block_start = nil
for i = 1, row do
Expand Down

0 comments on commit e6c735b

Please sign in to comment.