fix: restore cursor to correct position on picker close
#2850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I think we have several factors contributing to flaky (off by one error) behaviors in the cursor position on picker close.
Mainly, I think we should be scheduling
nvim_win_set_cursor
. Without doing so, we've had to "arbitrarily" +1 on the columns to compensate:telescope.nvim/lua/telescope/actions/set.lua
Lines 214 to 216 in 87e92ea
This is made worse by a couple of other factors
nvim_win_set_cursor
expects 0-index.This wasn't previously an issue probably due to not scheduling
nvim_win_set_cursor
but I think we were just depending on UB.not accounting for original mode onselect_default
. like thisI think this is no longer necessary and was used to compensate for the lack of scheduling set cursor.
telescope.nvim/lua/telescope/actions/init.lua
Lines 388 to 390 in 87e92ea
I recognize this is a very sensitive part of our code that we've had repeat issues with so I still need to do some testing and verify this closes a few issues without any obvious or previously experienced regressions
closes #2319 and semi-related #2319 (comment)
closes #2849
closes #1366
TODO (all with both norma/insert mode as original mode):
--invert-match
for no col info)actions.close()
calls (like in Wrong cursor position after actions.close #2849)