This commit is contained in:
bhagwan 2021-09-05 10:31:41 -07:00
parent 2617aa1587
commit ce30520aef
4 changed files with 11 additions and 14 deletions

View File

@ -263,6 +263,10 @@ M.fzf_files_interactive = function(opts)
opts = opts or config.normalize_opts(opts, config.globals.files) opts = opts or config.normalize_opts(opts, config.globals.files)
if not opts then return end if not opts then return end
-- cannot be nil
local query = opts._live_query or ''
local placeholder = utils._if(opts._is_skim, '"{}"', '{q}')
local uv = vim.loop local uv = vim.loop
local raw_async_act = require("fzf.actions").raw_async_action(function(pipe, args) local raw_async_act = require("fzf.actions").raw_async_action(function(pipe, args)
local shell_cmd = opts._cb_live_cmd(args[1]) local shell_cmd = opts._cb_live_cmd(args[1])
@ -310,18 +314,10 @@ M.fzf_files_interactive = function(opts)
output_pipe:read_start(read_cb) output_pipe:read_start(read_cb)
error_pipe:read_start(read_cb) error_pipe:read_start(read_cb)
end) end, placeholder)
local act_cmd = raw_async_act local act_cmd = raw_async_act
-- cannot be nil
local query = opts._live_query or ''
local placeholder = utils._if(opts._is_skim, '"{}"', '{q}')
-- HACK: nvim-fzf action rg assumes preview placeholder '{+}'
-- replace it with the correct query placeholder
act_cmd = act_cmd:gsub("{%+}", placeholder)
if opts._is_skim then if opts._is_skim then
-- do not run an empty string query unless the user requested -- do not run an empty string query unless the user requested
if not opts.exec_empty_query then if not opts.exec_empty_query then

View File

@ -326,7 +326,7 @@ function Previewer:action(_)
local entry = path.entry_to_file(items[1], self.opts.cwd) local entry = path.entry_to_file(items[1], self.opts.cwd)
self:display_entry(entry) self:display_entry(entry)
return "" return ""
end) end, "{}")
return act return act
end end

View File

@ -51,7 +51,7 @@ end
function Previewer.cmd:action(o) function Previewer.cmd:action(o)
o = o or {} o = o or {}
local filespec = "{+}" local filespec = "{}"
if self.opts._line_placeholder then if self.opts._line_placeholder then
filespec = "{1}" filespec = "{1}"
end end
@ -122,7 +122,7 @@ function Previewer.cmd_async:cmdline(o)
-- uncomment to see the command in the preview window -- uncomment to see the command in the preview window
-- cmd = vim.fn.shellescape(cmd) -- cmd = vim.fn.shellescape(cmd)
return cmd return cmd
end) end, "{}")
return act return act
end end
@ -151,7 +151,7 @@ function Previewer.bat_async:cmdline(o)
-- uncomment to see the command in the preview window -- uncomment to see the command in the preview window
-- cmd = vim.fn.shellescape(cmd) -- cmd = vim.fn.shellescape(cmd)
return cmd return cmd
end) end, "{}")
return act return act
end end
@ -182,7 +182,7 @@ function Previewer.git_diff:cmdline(o)
-- uncomment to see the command in the preview window -- uncomment to see the command in the preview window
-- cmd = vim.fn.shellescape(cmd) -- cmd = vim.fn.shellescape(cmd)
return cmd return cmd
end) end, "{}")
return act return act
end end

View File

@ -86,6 +86,7 @@ end
M.branches = function(opts) M.branches = function(opts)
opts = config.normalize_opts(opts, config.globals.git.branches) opts = config.normalize_opts(opts, config.globals.git.branches)
if not opts then return end if not opts then return end
opts.nomulti = true
opts._preview = path.git_cwd(opts.preview, opts.cwd) opts._preview = path.git_cwd(opts.preview, opts.cwd)
opts.preview = fzf_helpers.choices_to_shell_cmd_previewer(function(items) opts.preview = fzf_helpers.choices_to_shell_cmd_previewer(function(items)
local branch = items[1]:gsub("%*", "") -- remove the * from current branch local branch = items[1]:gsub("%*", "") -- remove the * from current branch