-
Notifications
You must be signed in to change notification settings - Fork 197
fix: move cursor left when exiting vi insert mode with Escape #986
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
base: main
Are you sure you want to change the base?
fix: move cursor left when exiting vi insert mode with Escape #986
Conversation
In vim, pressing Escape to exit insert mode moves the cursor left by one position. This is because insert mode positions the cursor between characters, while normal mode positions it on a character. Without this fix, repeatedly pressing "i <esc> i <esc>" would not move the cursor backward as expected in vim.
|
Thanks for trying to improve vi keybindings. I see the point of aligning the behaviors of reedline vi-mode with those of vim/neovim. But I don't think this specific one is very useful. It somehow reveals that we may have a bigger issue of wrong calculations of cursor positions within vi mode, see also #927. It would be better to fix them all-together with some fundamental changes/redesigning than this kind of case-wise tuning. |
|
Hmmm makes sense. |
you want literally 1:1? what must be added |
Not necessarily, just taking those off-by-1 issues like #766 into account. And you may find a better way to fix them.
Actually I don't have a clear view of how to do it. |
|
I agree with @blindFS that we should try to fix the source of the off-by-ones rather than fix individual issues downstream. By the way, we already had a PR for this with a very similar implementation: #699. It got reverted in #773 because it broke history search somehow: #772. I'm not sure if your implementation suffers from the same bug, but make sure to test that. |
|
I thought this looked familiar. Thanks yash! I agree with yash and bfs. |
|
btw I currently do not have capacity to make improvements to this so feel free to take over if this impl is best fit. |
Summary
i <esc> i <esc>would not move the cursor backward as expectedTest plan
esc_from_insert_mode_moves_cursor_left