Skip to content

Commit 939a731

Browse files
committed
fix: close pipe when actions error
Fix #1901 (reply in thread). If pipe is not closed, terminal won't response and refresh unless we press a ctrl-c
1 parent 494af9d commit 939a731

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lua/fzf-lua/shell.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ end
113113

114114
function M.raw_action(fn, fzf_field_expression, debug)
115115
local receiving_function = function(pipe, ...)
116-
local ret = fn(...)
116+
local ok, ret = pcall(fn, ...)
117117

118118
local on_complete = function(_)
119119
-- We are NOT asserting, in case fzf closes
@@ -122,6 +122,9 @@ function M.raw_action(fn, fzf_field_expression, debug)
122122
uv.close(pipe)
123123
end
124124

125+
-- pipe must be closed, otherwise terminal will freeze
126+
if not ok then on_complete() end
127+
125128
if type(ret) == "string" then
126129
uv.write(pipe, ret, on_complete)
127130
elseif type(ret) == nil then

0 commit comments

Comments
 (0)