Skip to content

Conversation

@deepeshraghav
Copy link

@deepeshraghav deepeshraghav commented Jan 27, 2026

After recalling a multiline history entry, key_repeats could remain non-zero,
causing Ctrl-A to be interpreted as a repeated key press. This resulted in the
cursor jumping to the start of the entire input on first Ctrl-A.

This change ensures that:

Ctrl-A once moves to the start of the current line

Repeated Ctrl-A still moves to the start of the input

#AI tools were used to assist with code exploration and reasoning; all changes were implemented and verified manually.

Fixes #60779

Fix a bug where pressing Ctrl-A after recalling multi-line history with
Ctrl-Up would incorrectly jump to the beginning of the entire input instead
of the beginning of the current line.

The issue was that history_prev() and history_next() used a temporary
key_repeats reset (via reset_key_repeats helper) that didn't also reset
previous_key. This left stale key state that caused the first keystroke
after history recall to be incorrectly treated as a repeated key,
triggering the 'jump to input start' behavior instead of 'go to line start'.

The fix replaces the temporary reset with a permanent reset of both
key_repeats and previous_key, which is semantically correct since
history recall creates a fresh editing context.

Changes:
- stdlib/REPL/src/REPL.jl: Modified history_prev() and history_next() to
  permanently reset key_repeats and previous_key
- stdlib/REPL/test/repl.jl: Added regression test to verify key_repeats
  and previous_key are reset after history recall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REPL: moving to beginning of line broken after selecting previous history item

2 participants