reedline icon indicating copy to clipboard operation
reedline copied to clipboard

Line editor selects two characters instead of one

Open LemmusLemmus opened this issue 9 months ago • 6 comments

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

  1. Write a couple of characters in the line editor, e.g. 123456789.
  2. Position the caret in-between, e.g. after the 3, 123|456789.
  3. Use e.g. shift + left arrow and observe that both the character 3 and the character 4 have 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

LemmusLemmus avatar Mar 22 '25 16:03 LemmusLemmus

probably a reedline issue as well. you can try to repro in the demo example to see for sure.

fdncred avatar Mar 22 '25 16:03 fdncred

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!

LemmusLemmus avatar Mar 22 '25 18:03 LemmusLemmus

Thanks for the research. It would be great to get this fixed.

fdncred avatar Mar 22 '25 19:03 fdncred

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)

sholderbach avatar Mar 22 '25 21:03 sholderbach

Has there been any recent motion on this? This is an issue I'm running into regularly.

collinmurch avatar Jun 28 '25 05:06 collinmurch

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.

collinmurch avatar Jun 30 '25 03:06 collinmurch