Skip to content

Commit

Permalink
fix: git status parse error for large stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
amedama41 committed Sep 10, 2023
1 parent 118d5bb commit 65371fe
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/vfiler/libs/async/jobs/job_nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,19 @@ function Job:start(command, options)
end
end,
}
local data_buffer = ''
if options.on_received then
jobopts.on_stdout = function(channel, datas, name)
for _, data in ipairs(datas) do
datas[1] = data_buffer .. datas[1]
local data_len = #datas
if datas[data_len] ~= '' then
data_buffer = datas[data_len]
data_len = data_len - 1
else
data_buffer = ''
end
for i = 1, data_len do
local data = datas[i]
if #data > 0 then
options.on_received(self, data)
end
Expand All @@ -35,6 +45,9 @@ function Job:start(command, options)
end
if options.on_completed then
jobopts.on_exit = function(id, code, event)
if options.on_received and data_buffer ~= '' then
options.on_received(self, data_buffer)
end
options.on_completed(self, code)
end
end
Expand Down

0 comments on commit 65371fe

Please sign in to comment.