Skip to content

Commit 2b69dab

Browse files
committed
fix(fzf_live): with string shell commands
1 parent fd2339d commit 2b69dab

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

lua/fzf-lua/core.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ M.fzf_live = function(contents, opts)
176176
-- convert "reload" actions to fzf's `reload` binds
177177
-- convert "exec_silent" actions to fzf's `execute-silent` binds
178178
shell.clear_protected()
179+
if type(contents) == "string" then
180+
-- Signal to stringify_mt we are relocating <query>
181+
-- Signal to preprocess we are looking to replace {argvz}
182+
-- Append query placeholder if not found in command
183+
opts.argv_expr = opts.multiprocess
184+
if not contents:match(M.fzf_query_placeholder) then
185+
contents = ("%s %s"):format(contents, M.fzf_query_placeholder)
186+
end
187+
end
179188
opts.fn_reload = shell.stringify(contents, opts, nil, true)
180189
local fzf_field_index = M.fzf_field_index(opts)
181190
local cmd = M.expand_query(opts.fn_reload, fzf_field_index)

lua/fzf-lua/providers/grep.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,6 @@ M.live_grep = function(opts)
294294
opts.multiprocess = opts.multiprocess and 1
295295
end
296296

297-
-- signal to preprocess we are looking to replace {argvz}
298-
opts.argv_expr = opts.multiprocess
299-
300297
-- this will be replaced by the appropriate fzf
301298
-- FIELD INDEX EXPRESSION by 'fzf_exec'
302299
local cmd = get_grep_cmd(opts, core.fzf_query_placeholder, 2)

lua/fzf-lua/shell.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ M.stringify_mt = function(cmd, opts)
215215
-- NOTE: since we cannot guarantee the positional index
216216
-- of arguments (#291), we use the last argument instead
217217
opts.cmd = opts.cmd:gsub(FzfLua.core.fzf_query_placeholder, "{argvz}")
218+
-- Must have preprocess to relocate {argvz}
219+
opts.fn_preprocess = opts.fn_preprocess == nil
220+
and [[return require("fzf-lua.make_entry").preprocess]]
221+
or opts.fn_preprocess
218222
end
219223
local spawn_cmd = libuv.wrap_spawn_stdio(
220224
serialize(filter_opts(opts)),

0 commit comments

Comments
 (0)