-
-
Notifications
You must be signed in to change notification settings - Fork 806
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
Wrong cursor position after actions.close #2849
Comments
I found, that the builtin |
Telescope sets the cursor column to +1, so after the telescope window closed, the cursor is off by one which makes some operations to insert to the wrong position. To fix, restore the position to the original Related issue: nvim-telescope/telescope.nvim#2849
Thanks for reporting. This is something we've been tracking and struggling to get a clean fix. |
If you can give the PR a try, that'll be helpful. |
Sure, it's #2850, right? My code works correctly with it, but executing a command with I'm using my runcmd plugin for testing. (Simplified version of it attached to the issue in the Minimal config section) These are the lua functions I use: local function pos()
local curpos = vim.fn.getpos(".")
return vim.api.nvim_put({vim.inspect(curpos)}, "", false, true)
end
vim.api.nvim_create_user_command("Pos", pos, {})
local function feed_pos()
local cr = vim.api.nvim_replace_termcodes("<cr>", true, false, true)
return vim.api.nvim_feedkeys((":Pos" .. cr), "t", false)
end
local function exec_pos()
return vim.cmd("Pos")
end
vim.api.nvim_create_user_command("FeedPos", feed_pos, {})
vim.api.nvim_create_user_command("ExecPos", exec_pos, {})
vim.g.runcmd_commands = {
runcmd.new_command("FeedPos", feed_pos),
runcmd.new_command("ExecPos", exec_pos),
} Calling the If I print the current position before and after calling the |
Pushed another commit. Should fix this as well. Just throwing |
That works, thanks. I'm still worried a bit about regressions. Do you have an idea what is happening here, where is the wrong position coming from? |
My theory is that we were setting cursor positions or allowing subsequent commands that set cursor positions too early in the vim event loop before it was "safe" to do so. Conni (another maintainer) and I will continue to use the PR branch for a few days to get some level of confidence then merge it into master and allow others riding the master branch to catch anything we might've missed. |
@jamestrew I stumbled upon this issue, because I also observe this wrong behavior while playing through the Telescope tutorial. Is there any chance, that #2850 will get merged soon? |
Original attempt at fixing this had some issues. |
Description
The cursor position is off by 1 character after calling
actions.close()
telescope.nvim/lua/telescope/actions/init.lua
Line 389 in 87e92ea
It causes issue when we try to change the text at the cursor after an entry has been selected in treesitter.
My suggested solution is to remove the
+ 1
from the line above.Neovim version
Operating system and version
Debian Bookworm
Telescope version / branch / rev
master
checkhealth telescope
Steps to reproduce
Open nvim with the provided minimal config
Add some text to the buffer, eg:
##
Place the cursor between the two characters (
#|#
), then type the:OpenPicker
, then select the "Insert text" entry by pressing enter.Expected behavior
I expected to add the
inserted text
between the two characters, so to have#inserted text#
text in the bufferActual behavior
The text added after the cursor,
##inserted text
If you use the user command
:InserthTheText
, it will add the text to the correct place.Minimal config
The text was updated successfully, but these errors were encountered: