From 9fc1b5111e9c04b802ad1efb3535af66a20251f6 Mon Sep 17 00:00:00 2001 From: aarondill Date: Fri, 17 May 2024 23:42:49 -0500 Subject: [PATCH] fix: Check for nil chunks when reading lines This fixes #169 @amirbilu --- lua/tabnine/utils.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/tabnine/utils.lua b/lua/tabnine/utils.lua index 2ab88f8..eee8985 100644 --- a/lua/tabnine/utils.lua +++ b/lua/tabnine/utils.lua @@ -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