fix: exiting picker from insert mode (#1202)

This commit is contained in:
fdschmidt93
2022-05-20 09:18:27 +02:00
committed by GitHub
parent 7bc8efd77b
commit b4c45e8c61
3 changed files with 6 additions and 2 deletions

View File

@@ -343,14 +343,17 @@ end
--- Close the Telescope window, usually used within an action
---@param prompt_bufnr number: The prompt bufnr
actions.close = function(prompt_bufnr)
action_state.get_current_history():reset()
local picker = action_state.get_current_picker(prompt_bufnr)
local original_win_id = picker.original_win_id
local original_cursor = a.nvim_win_get_cursor(original_win_id)
actions.close_pum(prompt_bufnr)
require("telescope.pickers").on_close_prompt(prompt_bufnr)
pcall(a.nvim_set_current_win, original_win_id)
if a.nvim_get_mode().mode == "i" then
pcall(a.nvim_win_set_cursor, original_win_id, { original_cursor[1], original_cursor[2] + 1 })
end
end
--- Close the Telescope window, usually used within an action<br>

View File

@@ -131,7 +131,7 @@ action_set.edit = function(prompt_bufnr, command)
local entry_bufnr = entry.bufnr
local picker = action_state.get_current_picker(prompt_bufnr)
require("telescope.actions").close(prompt_bufnr)
require("telescope.pickers").on_close_prompt(prompt_bufnr)
local win_id = picker.get_selection_window(picker, entry)
if picker.push_cursor_on_edit then

View File

@@ -1416,6 +1416,7 @@ end
function pickers.on_close_prompt(prompt_bufnr)
local status = state.get_status(prompt_bufnr)
local picker = status.picker
require("telescope.actions.state").get_current_history():reset()
if type(picker.cache_picker) == "table" then
local cached_pickers = state.get_global_key "cached_pickers" or {}