@@ -957,45 +957,6 @@ M.set_header = function(opts, hdr_tbl)
957957 return opts
958958end
959959
960-
961- -- Use both {q} and {+} as field indexes so we can update last query when
962- -- executing the action, without this we lose the last query on "hide" as
963- -- the process never terminates and `--print-query` isn't being printed
964- -- When no entry selected (with {q} {+}), {+} will be forced expand to ''
965- -- Use {n} to know if we really select an empty string, or there's just no selected
966- local patch_shell_action = function (v , opts )
967- local field_index = v .field_index == false and " " or v .field_index or " {+}"
968- local overide_f_idx
969- if not field_index :match (" ^{q} {n}" ) then
970- field_index = " {q} {n} " .. field_index
971- overide_f_idx = true
972- end
973- -- replace the action with shell cmd proxy to the original action
974- return shell .stringify_data (function (items , _ , _ )
975- assert (field_index :match (" ^{q} {n}" ))
976- local query , idx = unpack (items , 1 , 2 )
977- config .resume_set (" query" , query , opts )
978- if overide_f_idx then
979- table.remove (items , 1 )
980- table.remove (items , 1 )
981- end
982- -- fix side effect of "{q} {+}": {+} is forced expanded to ""
983- -- only when: user didn't set v.field_index (otherwise it can be complex/unpredictable)
984- -- {n} used to determine if "zero-selected && zero-match", then patch: "" -> nil
985- if not v .field_index then
986- -- When no item is matching (empty list or non-matching query)
987- -- both {n} and {+} are expanded to "".
988- -- NOTE1: older versions of fzf don't expand {n} to "" (without match)
989- -- in such case the (empty) items table will be in `items[2]` (#1833)
990- -- NOTE2: on Windows, no match {n} is expanded to '' (#1836)
991- local zero_matched = not tonumber (idx )
992- local zero_selected = # items == 0 or (# items == 1 and # items [1 ] == 0 )
993- items = (zero_matched and zero_selected ) and {} or items
994- end
995- v .fn (items , opts )
996- end , opts , field_index )
997- end
998-
999960-- converts actions defined with "reload=true" to use fzf's `reload` bind
1000961-- provides a better UI experience without a visible interface refresh
1001962--- @param reload_cmd string ?
@@ -1057,18 +1018,18 @@ M.convert_reload_actions = function(reload_cmd, opts)
10571018 if type (v ) == " table" and v .reload then
10581019 -- Modified actions should not be considered in `actions.expect`
10591020 opts .actions [k ]._ignore = true
1060- local shell_action = patch_shell_action (v , opts )
10611021 if type (v .prefix ) == " string" and not v .prefix :match (" %+$" ) then
10621022 v .prefix = v .prefix .. " +"
10631023 end
10641024 if type (v .postfix ) == " string" and not v .postfix :match (" ^%+" ) then
10651025 v .postfix = " +" .. v .postfix
10661026 end
1027+ local cmd = shell .stringify_data2 (v .fn , opts , v .field_index or " {+}" )
10671028 opts .keymap .fzf [k ] = {
10681029 string.format (" %s%sexecute-silent(%s)+reload(%s)%s" ,
10691030 type (v .prefix ) == " string" and v .prefix or " " ,
10701031 unbind and (unbind .. " +" ) or " " ,
1071- shell_action ,
1032+ cmd ,
10721033 reload_cmd ,
10731034 type (v .postfix ) == " string" and v .postfix or " " ),
10741035 desc = v .desc or config .get_action_helpstr (v .fn )
@@ -1097,7 +1058,6 @@ M.convert_exec_silent_actions = function(opts)
10971058 assert (type (v .fn ) == " function" )
10981059 -- Modified actions should not be considered in `actions.expect`
10991060 opts .actions [k ]._ignore = true
1100- local shell_action = patch_shell_action (v , opts )
11011061 if type (v .prefix ) == " string" and not v .prefix :match (" %+$" ) then
11021062 v .prefix = v .prefix .. " +"
11031063 end
@@ -1117,13 +1077,14 @@ M.convert_exec_silent_actions = function(opts)
11171077 -- key-action pairs.
11181078 --
11191079 local has_fzf036 = utils .has (opts , " fzf" , { 0 , 36 })
1080+ local cmd = shell .stringify_data2 (v .fn , opts , v .field_index or " {+}" )
11201081 opts .keymap .fzf [k ] = {
11211082 string.format (" %sexecute-silent%s%s" ,
11221083 type (v .prefix ) == " string" and v .prefix or " " ,
11231084 -- prefer "execute-silent:..." unless we have postfix
11241085 has_fzf036 and type (v .postfix ) == " string"
1125- and string.format (" (%s)" , shell_action )
1126- or string.format (" :%s" , shell_action ),
1086+ and string.format (" (%s)" , cmd )
1087+ or string.format (" :%s" , cmd ),
11271088 -- can't use postfix since we use "execute-silent:..."
11281089 has_fzf036 and type (v .postfix ) == " string" and v .postfix or " " ),
11291090 desc = v .desc or config .get_action_helpstr (v .fn )
0 commit comments