fix: push history on refine (#2074)

This commit is contained in:
Simon Hauser
2022-07-16 09:56:33 +02:00
committed by GitHub
parent b79cd6c88b
commit 6bddc38c25

View File

@@ -66,8 +66,13 @@ action_generate.refine = function(prompt_bufnr, opts)
opts.reset_multi_selection = vim.F.if_nil(opts.reset_multi_selection, false) opts.reset_multi_selection = vim.F.if_nil(opts.reset_multi_selection, false)
opts.reset_prompt = vim.F.if_nil(opts.reset_prompt, true) opts.reset_prompt = vim.F.if_nil(opts.reset_prompt, true)
opts.sorter = vim.F.if_nil(opts.sorter, config.values.generic_sorter {}) opts.sorter = vim.F.if_nil(opts.sorter, config.values.generic_sorter {})
local push_history = vim.F.if_nil(opts.push_history, true)
local current_picker = action_state.get_current_picker(prompt_bufnr) local current_picker = action_state.get_current_picker(prompt_bufnr)
local current_line = action_state.get_current_line()
if push_history then
action_state.get_current_history():append(current_line, current_picker)
end
-- title -- title
if opts.prompt_title then if opts.prompt_title then
@@ -97,15 +102,14 @@ action_generate.refine = function(prompt_bufnr, opts)
end, end,
} }
if not opts.reset_multi_selection and action_state.get_current_line() ~= "" then if not opts.reset_multi_selection and current_line ~= "" then
opts.multi = current_picker._multi opts.multi = current_picker._multi
end end
if opts.prompt_to_prefix then if opts.prompt_to_prefix then
local prompt = action_state.get_current_line()
local current_prefix = current_picker.prompt_prefix local current_prefix = current_picker.prompt_prefix
local suffix = current_prefix ~= opts.prompt_prefix and current_prefix or "" local suffix = current_prefix ~= opts.prompt_prefix and current_prefix or ""
opts.new_prefix = suffix .. prompt .. " " .. opts.prompt_prefix opts.new_prefix = suffix .. current_line .. " " .. opts.prompt_prefix
end end
current_picker:refresh(new_finder, opts) current_picker:refresh(new_finder, opts)
end end