Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: push history on refine #2074

Merged
merged 1 commit into from
Jul 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lua/telescope/actions/generate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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_prompt = vim.F.if_nil(opts.reset_prompt, true)
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_line = action_state.get_current_line()
if push_history then
action_state.get_current_history():append(current_line, current_picker)
end

-- title
if opts.prompt_title then
Expand Down Expand Up @@ -97,15 +102,14 @@ action_generate.refine = function(prompt_bufnr, opts)
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
end

if opts.prompt_to_prefix then
local prompt = action_state.get_current_line()
local current_prefix = current_picker.prompt_prefix
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
current_picker:refresh(new_finder, opts)
end
Expand Down