Skip to content

Commit

Permalink
fix: Check for nil chunks when reading lines (#171)
Browse files Browse the repository at this point in the history
This fixes #169
  • Loading branch information
aarondill authored May 18, 2024
1 parent 66cf807 commit a9baab6
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 a9baab6

Please sign in to comment.