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: correctly restore cursor position in original window #2336

Merged
merged 2 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
always exit in normal mode to prevent cursor movement
  • Loading branch information
cristiansofronie authored and Conni2461 committed May 24, 2023
commit ceeb068250c46af778713f652c16fff31d93ed52
10 changes: 0 additions & 10 deletions lua/telescope/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -371,18 +371,8 @@ end
--- Close the Telescope window, usually used within an action
---@param prompt_bufnr number: The prompt bufnr
actions.close = function(prompt_bufnr)
local picker = action_state.get_current_picker(prompt_bufnr)
local original_win_id = picker.original_win_id
local cursor_valid, original_cursor = pcall(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 cursor_valid and a.nvim_get_mode().mode == "i" and picker._original_mode ~= "i" then
vim.defer_fn(function()
pcall(a.nvim_win_set_cursor, original_win_id, { original_cursor[1], original_cursor[2] })
end, 0)
end
end

--- Close the Telescope window, usually used within an action<br>
Expand Down
7 changes: 6 additions & 1 deletion lua/telescope/pickers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,12 @@ function pickers.on_close_prompt(prompt_bufnr)
event = "BufLeave",
buffer = prompt_bufnr,
}
picker.close_windows(status)

vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<esc>", true, true, true), "n", true)
vim.defer_fn(function()
picker.close_windows(status)
end, 0)

mappings.clear(prompt_bufnr)
end

Expand Down