reedline icon indicating copy to clipboard operation
reedline copied to clipboard

`Move(Big)WordRightEnd` is off-by-1 in insert mode

Open bew opened this issue 1 year ago • 1 comments

Platform Linux (NixOS) Terminal software Wezterm

Using nushell 0.91.0

Steps to reproduce

  1. In your nushell config, setup a keybind with:
     {
       name: move_to_end_word
       mode: [emacs vi_insert vi_normal]
       modifier: Alt keycode: Char_e
       event: {edit: MoveWordRightEnd}
     }
     {
       name: move_to_end_WORD
       mode: [emacs vi_insert vi_normal]
       modifier: Alt_Shift keycode: Char_E
       event: {edit: MoveBigWordRightEnd}
     }
    
  2. Write this is some/cmd in nushell
  3. Put cursor on s of some, make sure you are in insert mode: this is |some/cmd
  4. Do Alt-e, cursor is now between m & e instead of between e & /: this is som|e/cmd
  5. Do Alt-E, cursor is now between m & d instead of at the end of the input buffer: this is some/cm|d

Note that normal mode works okay, only insert mode isn't working correctly.

Screenshots/Screencaptures

https://github.com/nushell/reedline/assets/9730330/e722ee81-df56-4c77-9ca4-6a6fa898df8d

bew avatar Mar 09 '24 19:03 bew

Good catch!

This is another case where our vi emulation breaks down.

The Editor/LineBuffer don't know anything about the Vi mode and just get EditCommands we emit in the emulation layer. The word moves where designed with the cursor position reflecting the normal mode but the shifted cursor in insert mode was not taken into account (see also the recent #699 )

sholderbach avatar Mar 11 '24 11:03 sholderbach