fix(readline): C-n at the current line dings instead of clearing it - #652
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_historydidn't check whether the cursor was already on the line being edited. With no forward entry,next_history()returned null and the code restoredsaved_line— empty at a fresh prompt — wiping the text. Now it returnsrl_ding()when already at the bottom (where_history() == history_length), leaving the line untouched, as bash does.Testing (pty + pyte, vs bash)
hellothenC-n→ line stillhello(was cleared) ✓C-p(up),C-n(down) → draft restored ✓C-p C-p C-n(mid-history) → correct middle entry ✓Closes #651