Skip to content

Commit

Permalink
fix: Check for nil chunks when reading lines
Browse files Browse the repository at this point in the history
This fixes #169
  • Loading branch information
aarondill committed May 18, 2024
1 parent db3d8d0 commit 48d3f00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lua/tabnine/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ end
function M.read_lines_start(stream, on_line, on_error)
local buffer = ""
stream:read_start(function(error, chunk)
buffer = buffer .. chunk
if error then
on_error(error)
return
end
-- if there's no new chunk, wait until one is recieved.
if not chunk then return end
buffer = buffer .. chunk
while true do
local start_pos = buffer:find("\n")
if not start_pos then break end
Expand Down

0 comments on commit 48d3f00

Please sign in to comment.