reedline icon indicating copy to clipboard operation
reedline copied to clipboard

fix: move cursor left when exiting vi insert mode with Escape

Open andrewgazelka opened this issue 1 week ago • 3 comments

Summary

  • 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

Test plan

  • [x] Added test esc_from_insert_mode_moves_cursor_left
  • [x] Updated existing test to explicitly test Esc from normal mode
  • [x] All 756 tests pass

andrewgazelka avatar Dec 16 '25 03:12 andrewgazelka

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.

blindFS avatar Dec 16 '25 04:12 blindFS

Hmmm makes sense.

andrewgazelka avatar Dec 16 '25 16:12 andrewgazelka

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.

you want literally 1:1? what must be added

andrewgazelka avatar Dec 16 '25 17:12 andrewgazelka

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.

you want literally 1:1?

Not necessarily, just taking those off-by-1 issues like #766 into account. And you may find a better way to fix them.

what must be added

Actually I don't have a clear view of how to do it.

blindFS avatar Dec 17 '25 02:12 blindFS