Line editor selects two characters instead of one
Describe the bug
I normally use shift + arrow keys to select one character at a time in the line editor. However, now when I start to select text, two characters are always initially selected (one extra to the right of the caret), except when selecting the very last character (in which case it works as expected, since there is no extra character to the right of it).
This seems to be a regression. Everything works fine on version 0.100.0, but it is not working correctly on 0.103.0.
How to reproduce
- Write a couple of characters in the line editor, e.g.
123456789. - Position the caret in-between, e.g. after the
3,123|456789. - Use e.g. shift + left arrow and observe that both the character
3and the character4have been selected.
Expected behavior
I expect a single press of shift + left/right arrow to only select at most one character.
Configuration
| key | value |
|---|---|
| version | 0.103.0 |
| major | 0 |
| minor | 103 |
| patch | 0 |
| branch | |
| commit_hash | |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.85.0 (4d91de4e4 2025-02-17) (built from a source tarball) |
| cargo_version | cargo 1.85.0 (d73d2caf9 2024-12-31) |
| build_time | 1980-01-01 00:00:00 +00:00 |
| build_rust_channel | release |
| allocator | standard |
| features | default, sqlite, trash |
| installed_plugins |
probably a reedline issue as well. you can try to repro in the demo example to see for sure.
I ran the demo and yep. The issue occurs only in the latest version of reedline: 0.39.0.
Specifically, commit nushell/reedline@853cde5d8be373e8897879171ba139a1135ee64c seems to have introduced the bug (nushell/reedline@abb5c08d79b6e42826c32dbd4f4bef178efff1fb was the last working version).
Feel free to move this issue to the reedline repo!
Thanks for the research. It would be great to get this fixed.
Yeah in trying to focus to fix the selection behavior for vi mode this broke for the non modal bindings.
So just reverting whatever change there would break it on the opposite side. (recurring observation that we have too many config options, modes etc. to test manually)
Has there been any recent motion on this? This is an issue I'm running into regularly.
Fix MR: https://github.com/nushell/reedline/pull/927, apologies for the above (ignore #926 please) MR. I think we want to take a simpler & cleaner approach in #927.