@@ -155,7 +155,8 @@ M.fzf_exec = function(contents, opts)
155155 -- the API accepts both tables and functions which we "stringify"
156156 -- We also send string commands as stringify is also responsible
157157 -- for multiprocess wrapping of shell commands with processing
158- contents = contents and shell .stringify (contents , opts ) or nil
158+ shell .clear_protected ()
159+ contents = contents and shell .stringify (contents , opts , nil , true ) or nil
159160 assert (contents == nil or type (contents ) == " string" , " contents must be of type string" )
160161 return M .fzf_wrap (contents , opts )
161162end
@@ -172,7 +173,10 @@ M.fzf_live = function(contents, opts)
172173 -- AKA "live": fzf acts as a selector only (fuzzy matching is disabled)
173174 -- each keypress reloads fzf's input usually based on the typed query
174175 -- utilizes fzf's 'change:reload' event or skim's "interactive" mode
175- opts .fn_reload = shell .stringify (contents , opts )
176+ -- convert "reload" actions to fzf's `reload` binds
177+ -- convert "exec_silent" actions to fzf's `execute-silent` binds
178+ shell .clear_protected ()
179+ opts .fn_reload = shell .stringify (contents , opts , nil , true )
176180 local fzf_field_index = M .fzf_field_index (opts )
177181 local cmd = M .expand_query (opts .fn_reload , fzf_field_index )
178182 contents , opts = M .setup_fzf_interactive_flags (cmd , fzf_field_index , opts )
@@ -190,7 +194,6 @@ M.fzf_resume = function(opts)
190194 assert (opts == config .__resume_data .opts )
191195 opts = M .set_header (opts , opts .headers or {})
192196 opts .cwd = opts .cwd and libuv .expand (opts .cwd ) or nil
193- opts .__resuming = true
194197 M .fzf_wrap (config .__resume_data .contents , config .__resume_data .opts )
195198end
196199
199202--- @return thread , string , table
200203M .fzf_wrap = function (contents , opts )
201204 opts = opts or {}
205+ -- Does nothing if already converted
206+ opts = M .convert_reload_actions (contents , opts )
207+ opts = M .convert_exec_silent_actions (opts )
202208 local _co
203209 local wrapped = coroutine.wrap (function ()
204210 _co = coroutine.running ()
@@ -315,11 +321,6 @@ M.fzf = function(contents, opts)
315321 opts .actions [k ] = actions .dummy_abort
316322 end
317323 end
318- if not opts .__resuming then
319- -- `opts.__resuming` is only set from `fzf_resume`, since we
320- -- not resuming clear the shell protected functions registry
321- shell .clear_protected ()
322- end
323324 -- store last call opts for resume
324325 config .resume_set (nil , opts .__call_opts , opts )
325326 -- caller specified not to resume this call (used by "builtin" provider)
@@ -392,10 +393,6 @@ M.fzf = function(contents, opts)
392393
393394 fzf_win :attach_previewer (previewer )
394395 local fzf_bufnr = fzf_win :create ()
395- -- convert "reload" actions to fzf's `reload` binds
396- -- convert "exec_silent" actions to fzf's `execute-silent` binds
397- opts = M .convert_reload_actions (contents , opts )
398- opts = M .convert_exec_silent_actions (opts )
399396 local selected , exit_code = fzf .raw_fzf (contents , M .build_fzf_cli (opts , fzf_win ),
400397 {
401398 fzf_bin = opts .fzf_bin ,
@@ -997,7 +994,7 @@ local patch_shell_action = function(v, opts)
997994 items = (zero_matched and zero_selected ) and {} or items
998995 end
999996 v .fn (items , opts )
1000- end , opts , field_index )
997+ end , opts , field_index , true )
1001998end
1002999
10031000-- converts actions defined with "reload=true" to use fzf's `reload` bind
@@ -1006,6 +1003,8 @@ end
10061003--- @param opts table
10071004--- @return table
10081005M .convert_reload_actions = function (reload_cmd , opts )
1006+ if opts .__converted_reload then return opts end
1007+ opts .__converted_reload = true
10091008 local fallback --- @type boolean ?
10101009 -- Does not work with fzf version < 0.36, fzf fails with
10111010 -- "error 2: bind action not specified:" (#735)
@@ -1083,7 +1082,8 @@ M.convert_reload_actions = function(reload_cmd, opts)
10831082 -- NOTE: this fixes existence of both load as function and rebind, e.g. git_status with:
10841083 -- setup({ keymap = { fzf = { true, load = function() _G._fzf_load_called = true end } } }
10851084 if type (opts .keymap .fzf .load ) == " function" then
1086- opts .keymap .fzf .load = " execute-silent:" .. shell .stringify_data (opts .keymap .fzf .load , opts )
1085+ opts .keymap .fzf .load = " execute-silent:"
1086+ .. shell .stringify_data (opts .keymap .fzf .load , opts , nil , true )
10871087 end
10881088 if rebind and type (opts .keymap .fzf .load ) == " string" then
10891089 return string.format (" %s+%s" , rebind , opts .keymap .fzf .load )
@@ -1099,6 +1099,8 @@ end
10991099--- @param opts table
11001100--- @return table
11011101M .convert_exec_silent_actions = function (opts )
1102+ if opts .__converted_exec_silent then return opts end
1103+ opts .__converted_exec_silent = true
11021104 -- `execute-silent` actions are bugged with skim (can't use quotes)
11031105 if utils .has (opts , " sk" ) then
11041106 return opts
0 commit comments