nushell / reedline

A feature-rich line editor - powering Nushell
https://docs.rs/reedline/
MIT License
497 stars 134 forks source link

vi keybinds are wrong and/or inconsistent with readline #788

Open Atemu opened 1 month ago

Atemu commented 1 month ago

Describe the bug

I've noticed a couple of issues with the vi keybinds:

  1. Exiting insert mode keeps the cursor position
  2. Some punctuation chars do not separate words and are jumped across with lower case inputs
  3. When jumping to the previous line/history item, the cursor is not reset to the start of the line
  4. You can navigate to the EOL char in normal mode
  5. Navigating downwards from a history item after navigating away from the EOL char navigates back to the EOL char of the same history item
  6. You cannot navigate away from an history item after navigating to any char but the EOL char
  7. You are jumped to the most recent history item when trying to navigate up from a history item after having jumped away from EOL

How to reproduce

  1. Enter some text into the prompt, navigate to the EOL and alternate i and <ESC>
  2. Navigate foo.bar:baz using e, w, b etc.
  3. Exit insert mode, k
  4. Enter some text and navigate to the end ($)
  5. <ESC> k h j
  6. <ESC> k h l j k
  7. <ESC> k h k

Expected behavior

  1. The cursor should jump one char backwards after <ESC>
  2. The cursor should stop before/after all punctuation
  3. The cursor should jump to the beginning of the line (bash does this but zsh doesn't? Perhaps this should be configurable.)
  4. The cursor should stop at the last non-EOL char
  5. It should just jump to the next history item
  6. You should be able to move in any history direction, no matter what you did previously
  7. You should go up in the history

Screenshots

No response

Configuration

key value
version 0.92.1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.77.1 (7cf61ebde 2024-03-27) (built from a source tarball)
cargo_version cargo 1.77.1
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which
installed_plugins

Additional context

No response

kubouch commented 1 month ago

I believe this belongs to reedline as the vi mode is a feature of reedline. The vi mode is not very developed, improvements are welcome.

amtoine commented 1 month ago

yeah, i've seen some clear differences with Vim over the years...

the easiest has always been to hit <c-o> and drop inside Neovim, my $env.EDITOR :rofl: