summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorfdschmidt93 <39233597+fdschmidt93@users.noreply.github.com>2022-05-20 09:18:27 +0200
committerGitHub <noreply@github.com>2022-05-20 09:18:27 +0200
commitb4c45e8c610c8dc60483b49936dee8a4d0b9c532 (patch)
treebe1a518af34dbd5e5c65a1edb7cbebb6f356d798 /lua
parent7bc8efd77bc99f8e0bdf49b68f11ba9de731b45c (diff)
fix: exiting picker from insert mode (#1202)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/actions/init.lua5
-rw-r--r--lua/telescope/actions/set.lua2
-rw-r--r--lua/telescope/pickers.lua1
3 files changed, 6 insertions, 2 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua
index 11b46a2..d448e79 100644
--- a/lua/telescope/actions/init.lua
+++ b/lua/telescope/actions/init.lua
@@ -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>
diff --git a/lua/telescope/actions/set.lua b/lua/telescope/actions/set.lua
index 4faf947..3164f72 100644
--- a/lua/telescope/actions/set.lua
+++ b/lua/telescope/actions/set.lua
@@ -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
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index e7c4c7c..c4aa6fc 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -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 {}