Skip to content

Commit

Permalink
read lines for binary
Browse files Browse the repository at this point in the history
  • Loading branch information
amirbilu committed Apr 1, 2024
1 parent 743058f commit 9a18941
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lua/tabnine/binary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,17 @@ function TabnineBinary:start()
uv.read_stop(self.stdout)
end)

uv.read_start(
utils.read_lines_start(
self.stdout,
vim.schedule_wrap(function(error, chunk)
if chunk then
for _, line in pairs(utils.str_to_lines(chunk)) do
local callback = table.remove(self.callbacks)
if not callback.cancelled then
local decoded = vim.json.decode(line, { luanil = { object = true, array = true } })
callback.callback(decoded)
end
end
elseif error then
print("tabnine binary read_start error", error)
vim.schedule_wrap(function(line)
local callback = table.remove(self.callbacks)
if not callback.cancelled then
local decoded = vim.json.decode(line, { luanil = { object = true, array = true } })
callback.callback(decoded)
end
end),
vim.schedule_wrap(function(error)
print("tabnine binary read_start error", error)
end)
)
end
Expand Down

0 comments on commit 9a18941

Please sign in to comment.