Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiprocess mode pipes to use io.write() #252

Merged
merged 1 commit into from
Dec 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions lua/fzf-lua/libuv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ M.spawn_stdio = function(opts, fn_transform, fn_preprocess)
end)
end

stderr = pipe_open(opts.stderr or "/dev/stderr")

-- /dev/stdout seems to create issues on MacOS (#248, #251)
-- do not use a pipe unless use specifically requests it
-- instead we use 'io.write'
stdout = pipe_open(opts.stdout)
if opts.stderr then
stderr = pipe_open(opts.stderr)
end
if opts.stdout then
stdout = pipe_open(opts.stdout)
end

local on_finish = opts.on_finish or
function(code)
Expand All @@ -351,14 +351,19 @@ M.spawn_stdio = function(opts, fn_transform, fn_preprocess)
if stdout then
pipe_write(stdout, data, cb)
else
io.write(data)
io.stdout:write(data)
cb(nil)
end
end

local on_err = opts.on_err or
function(data)
pipe_write(stderr, data)
if stderr then
pipe_write(stderr, data)
else
io.stderr:write(data)
cb(nil)
end
end

return M.spawn({
Expand Down