Skip to content

fix(readline): C-n at the current line dings instead of clearing it - #652

Merged
brianjfox merged 1 commit into
mainfrom
fix/next-history-noclear
Aug 13, 2026
Merged

fix(readline): C-n at the current line dings instead of clearing it#652
brianjfox merged 1 commit into
mainfrom
fix/next-history-noclear

Conversation

@brianjfox

Copy link
Copy Markdown
Owner

Summary

At a fresh prompt, typing text then pressing C-n (next-history / down arrow) cleared the line. It should do nothing when there's no next entry to move to.

rl_get_next_history didn't check whether the cursor was already on the line being edited. With no forward entry, next_history() returned null and the code restored saved_line — empty at a fresh prompt — wiping the text. Now it returns rl_ding() when already at the bottom (where_history() == history_length), leaving the line untouched, as bash does.

Testing (pty + pyte, vs bash)

  • hello then C-n → line still hello (was cleared) ✓
  • type draft, C-p (up), C-n (down) → draft restored ✓
  • C-p C-p C-n (mid-history) → correct middle entry ✓
  • ctest 23/23; run_diff all 441 match (non-interactive corpus unaffected).

Closes #651

At a fresh prompt (or any time the cursor is on the line being edited
rather than navigated up into history), `next-history' had no forward
entry, so it fell through to restoring the saved line -- which is empty
there -- and wiped the typed text.

Return rl_ding() when already at the bottom (where_history() ==
history_length), leaving the line untouched, as bash does.  Stepping
down from an actual history entry still restores the typed draft.

Closes #651
@brianjfox
brianjfox merged commit c3f5b26 into main Aug 13, 2026
1 check passed
@brianjfox
brianjfox deleted the fix/next-history-noclear branch August 13, 2026 02:25
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.

C-n at a fresh prompt clears the typed line instead of doing nothing

1 participant