Open Martinits opened 1 year ago
This is weird. The problem seems to be when calling actions.close
. The
function contains the following line which sets the cursor:
pcall(a.nvim_win_set_cursor, original_win_id, { original_cursor[1], original_cursor[2] + 1 })
If I would wrap it in defer_fn
the cursor would be shifted all the times,
that is also when hitting vim.cmd
calls from
internal.man_pages
and internal.help_tags
in defer_fn
the problem would
go away.
The following line in actions.close
gets the cursor position where to move:
local cursor_valid, original_cursor = pcall(a.nvim_win_get_cursor, original_win_id)
I printed the position to the screen and it seems to be correct in both cases.
I used :lua print(vim.inspect(vim.api.nvim_win_get_cursor(0)))
before calling
the picker and checked the value with the one shown by the
print(vim.inspect(original_cursor))
I inserted after the call to
nvim_win_get_cursor
.
The problem as far as I can tell seems to be with nvim_win_set_cursor
having
some weird race conditions.
If in actions.close
I replace:
pcall(a.nvim_win_set_cursor, original_win_id, { original_cursor[1], original_cursor[2] + 1})
with
vim.defer_fn(function()
pcall(a.nvim_win_set_cursor, original_win_id, { original_cursor[1], original_cursor[2] })
end, 0)
The + 1
was added in commit b4c45e8c610c8dc60483b49936dee8a4d0b9c532. But if
we defer the call to nvim_win_set_cursor
it doesn't seem to be required any
more.
I can confirm that will fix this issue.
needs to be reverted in https://github.com/nvim-telescope/telescope.nvim/pull/2538 because it broke custom actions that rely that the picker is actually closed with actions.close
@Conni2461 is there a plan to re-fix this issue?
This column off by one error also happens when opening files in normal mode.
Description
When telescope closes, the cursor will strangely move right by 1 column. That will influence some other plugins like https://github.com/AckslD/nvim-neoclip.lua . Neoclip uses telescope to provide a selection of yank history, and paste the selected item where it launched. This strange move makes neoclip paste to a wrong position.(https://github.com/AckslD/nvim-neoclip.lua/issues/96). Also, if you launch
require('telescope.builtin').help_tag
, choose one and close the help window, the cursor will move right.Neovim version
Operating system and version
archlinux
Telescope version / branch / rev
master
checkhealth telescope
Steps to reproduce
Expected behavior
No response
Actual behavior
described above
Minimal config