Skip to content

Commit 68d9864

Browse files
committed
fix(libuv.spawn): last line with use_queue (closes #2205)
1 parent accfef9 commit 68d9864

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lua/fzf-lua/libuv.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ M.spawn = function(opts, fn_transform, fn_done)
134134
if write_cb_count == 0
135135
and read_cb_count == 0
136136
and not output_pipe:is_active()
137+
-- on_exit is called before queue processing of the last line (#2205)
138+
and (not opts.use_queue or queue:empty())
137139
then
138140
-- Do not call `:read_stop` or `:close` here as we may have data
139141
-- reads outstanding on slower Windows machines (#1521), only call
@@ -271,8 +273,11 @@ M.spawn = function(opts, fn_transform, fn_done)
271273
if opts.use_queue then
272274
if data then
273275
queue:push(data)
274-
coroutine.resume(co)
276+
elseif prev_line_content then
277+
queue:push(prev_line_content .. EOL)
278+
prev_line_content = nil
275279
end
280+
coroutine.resume(co)
276281
else
277282
-- Schedule data processing, will call finish if data is nil
278283
-- and no leftover data is present
@@ -319,8 +324,6 @@ M.spawn = function(opts, fn_transform, fn_done)
319324
process_data(queue:pop())
320325
end
321326
end
322-
-- process the leftover line from `processs_data`
323-
process_data(nil)
324327
end
325328

326329
return handle, pid

0 commit comments

Comments
 (0)