fix: exiting picker from insert mode (#1202)
This commit is contained in:
@@ -343,14 +343,17 @@ end
|
|||||||
--- Close the Telescope window, usually used within an action
|
--- Close the Telescope window, usually used within an action
|
||||||
---@param prompt_bufnr number: The prompt bufnr
|
---@param prompt_bufnr number: The prompt bufnr
|
||||||
actions.close = function(prompt_bufnr)
|
actions.close = function(prompt_bufnr)
|
||||||
action_state.get_current_history():reset()
|
|
||||||
local picker = action_state.get_current_picker(prompt_bufnr)
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
local original_win_id = picker.original_win_id
|
local original_win_id = picker.original_win_id
|
||||||
|
local original_cursor = a.nvim_win_get_cursor(original_win_id)
|
||||||
|
|
||||||
actions.close_pum(prompt_bufnr)
|
actions.close_pum(prompt_bufnr)
|
||||||
|
|
||||||
require("telescope.pickers").on_close_prompt(prompt_bufnr)
|
require("telescope.pickers").on_close_prompt(prompt_bufnr)
|
||||||
pcall(a.nvim_set_current_win, original_win_id)
|
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
|
end
|
||||||
|
|
||||||
--- Close the Telescope window, usually used within an action<br>
|
--- Close the Telescope window, usually used within an action<br>
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ action_set.edit = function(prompt_bufnr, command)
|
|||||||
local entry_bufnr = entry.bufnr
|
local entry_bufnr = entry.bufnr
|
||||||
|
|
||||||
local picker = action_state.get_current_picker(prompt_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)
|
local win_id = picker.get_selection_window(picker, entry)
|
||||||
|
|
||||||
if picker.push_cursor_on_edit then
|
if picker.push_cursor_on_edit then
|
||||||
|
|||||||
@@ -1416,6 +1416,7 @@ end
|
|||||||
function pickers.on_close_prompt(prompt_bufnr)
|
function pickers.on_close_prompt(prompt_bufnr)
|
||||||
local status = state.get_status(prompt_bufnr)
|
local status = state.get_status(prompt_bufnr)
|
||||||
local picker = status.picker
|
local picker = status.picker
|
||||||
|
require("telescope.actions.state").get_current_history():reset()
|
||||||
|
|
||||||
if type(picker.cache_picker) == "table" then
|
if type(picker.cache_picker) == "table" then
|
||||||
local cached_pickers = state.get_global_key "cached_pickers" or {}
|
local cached_pickers = state.get_global_key "cached_pickers" or {}
|
||||||
|
|||||||
Reference in New Issue
Block a user