Skip to content

Commit

Permalink
Revert "fix: correctly restore cursor position in original window (#2336
Browse files Browse the repository at this point in the history
)" (#2538)

This reverts commit 3f1b579.

(cherry picked from commit eb95a31)
  • Loading branch information
Conni2461 committed May 25, 2023
1 parent 7c2f0f8 commit 533c7fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 9 additions & 0 deletions lua/telescope/actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,17 @@ 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
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>
Expand Down
7 changes: 1 addition & 6 deletions lua/telescope/pickers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1493,12 +1493,7 @@ function pickers.on_close_prompt(prompt_bufnr)
event = "BufLeave",
buffer = prompt_bufnr,
}

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)

picker.close_windows(status)
mappings.clear(prompt_bufnr)
end

Expand Down

0 comments on commit 533c7fb

Please sign in to comment.