Skip to content

Commit 8627d83

Browse files
committed
test
1 parent c7780cb commit 8627d83

2 files changed

Lines changed: 29 additions & 25 deletions

File tree

lua/fzf-lua/config.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ function M.normalize_opts(opts, globals, __resume_key)
381381
end
382382
end
383383

384+
-- `fzf_cli_args` is string, `_fzf_cli_args` is a table used internally
385+
opts._fzf_cli_args = {}
386+
384387
-- backward compatibility, rhs overrides lhs
385388
-- (rhs being the "old" option)
386389
local backward_compat = {
@@ -921,8 +924,8 @@ function M.normalize_opts(opts, globals, __resume_key)
921924
utils.warn("'line_query' requires fzf >= 0.59, ignoring.")
922925
elseif opts.line_query then
923926
utils.map_set(opts, "winopts.preview.winopts.cursorline", true)
924-
utils.map_set(opts, "keymap.fzf.change",
925-
"transform:" .. FzfLua.shell.stringify_data(function(q, _, _)
927+
table.insert(opts._fzf_cli_args, "--bind=" .. libuv.shellescape("change:+transform:"
928+
.. FzfLua.shell.stringify_data(function(q, _, _)
926929
local lnum = q[1]:match(":(%d+)$")
927930
local new_q, subs = q[1]:gsub(":%d*$", "")
928931
-- No subs made, no ":" at end of string, do nothing
@@ -936,7 +939,7 @@ function M.normalize_opts(opts, globals, __resume_key)
936939
trans = string.format("%s+change-preview-window(%s:%s)", trans, optstr, offset)
937940
end
938941
return trans
939-
end, opts, "{q}"))
942+
end, opts, "{q}")))
940943
end
941944

942945
if type(opts.enrich) == "function" then

lua/fzf-lua/core.lua

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ M.fzf = function(contents, opts)
315315
opts = config.normalize_opts(opts or {}, {})
316316
if not opts then return end
317317
end
318+
-- Store contents for unhide
319+
opts._contents = contents
318320
-- flag used to print the query on stdout line 1
319321
-- later to be removed from the result by M.fzf()
320322
-- this provides a solution for saving the query
@@ -371,7 +373,8 @@ M.fzf = function(contents, opts)
371373
-- fzf 0.40 added 'zero' event for when there's no match
372374
-- clears the preview when there are no matching entries
373375
if utils.has(opts, "fzf", { 0, 40 }) and previewer.zero then
374-
utils.map_set(opts, "keymap.fzf.zero", previewer:zero())
376+
table.insert(opts._fzf_cli_args, "--bind="
377+
.. libuv.shellescape("zero:+" .. previewer:zero()))
375378
end
376379
if type(previewer.preview_window) == "function" then
377380
-- do we need to override the preview_window args?
@@ -751,8 +754,14 @@ M.build_fzf_cli = function(opts, fzf_win)
751754
end
752755
end
753756
for _, o in ipairs({ "fzf_args", "fzf_raw_args", "fzf_cli_args", "_fzf_cli_args" }) do
754-
if opts[o] then
755-
table.insert(cli_args, type(opts[o]) == "table" and opts[o] or tostring(opts[o]))
757+
local args = opts[o]
758+
if args then
759+
if type(args) ~= "table" then
760+
args = { tostring(args) }
761+
end
762+
for _, arg in ipairs(args) do
763+
table.insert(cli_args, arg)
764+
end
756765
end
757766
end
758767
return cli_args
@@ -1087,19 +1096,11 @@ M.convert_reload_actions = function(reload_cmd, opts)
10871096
}
10881097
end
10891098
end
1090-
opts.keymap.fzf.load = (function()
1091-
-- NOTE: this fixes existence of both load as function and rebind, e.g. git_status with:
1092-
-- setup({ keymap = { fzf = { true, load = function() _G._fzf_load_called = true end } } }
1093-
if type(opts.keymap.fzf.load) == "function" then
1094-
opts.keymap.fzf.load = "execute-silent:"
1095-
.. shell.stringify_data(opts.keymap.fzf.load, opts, nil, true)
1096-
end
1097-
if rebind and type(opts.keymap.fzf.load) == "string" then
1098-
return string.format("%s+%s", rebind, opts.keymap.fzf.load)
1099-
else
1100-
return rebind or opts.keymap.fzf.load
1101-
end
1102-
end)()
1099+
1100+
if rebind then
1101+
table.insert(opts._fzf_cli_args,
1102+
"--bind=" .. libuv.shellescape(string.format("load:+%s", rebind)))
1103+
end
11031104
return opts
11041105
end
11051106

@@ -1218,20 +1219,20 @@ M.setup_fzf_interactive_flags = function(command, fzf_field_index, opts)
12181219
opts.fzf_opts["--query"] = nil
12191220
opts.query = nil
12201221
-- setup as interactive
1221-
opts._fzf_cli_args = string.format("--interactive --cmd %s",
1222-
libuv.shellescape(no_query_condi .. reload_command))
1222+
table.insert(opts._fzf_cli_args, string.format("--interactive --cmd %s",
1223+
libuv.shellescape(no_query_condi .. reload_command)))
12231224
else
12241225
opts.fzf_opts["--disabled"] = true
12251226
opts.fzf_opts["--query"] = opts.query
12261227
-- OR with true to avoid fzf's "Command failed:" message
12271228
if opts.silent_fail ~= false then
12281229
reload_command = reload_command .. " || " .. utils.shell_nop()
12291230
end
1230-
opts._fzf_cli_args = string.format("--bind=%s", libuv.shellescape(
1231-
string.format("change:reload:%s%s", no_query_condi, reload_command)))
1231+
table.insert(opts._fzf_cli_args, "--bind="
1232+
.. libuv.shellescape(string.format("change:+reload:%s%s", no_query_condi, reload_command)))
12321233
if utils.has(opts, "fzf", { 0, 35 }) then
1233-
opts._fzf_cli_args = opts._fzf_cli_args .. string.format(" --bind=%s",
1234-
libuv.shellescape(string.format("start:reload:%s%s", no_query_condi, reload_command)))
1234+
table.insert(opts._fzf_cli_args, "--bind="
1235+
.. libuv.shellescape(string.format("start:+reload:%s%s", no_query_condi, reload_command)))
12351236
end
12361237
end
12371238

0 commit comments

Comments
 (0)