Don't let a menu with no suggestions swallow Enter - #1175
Open
shreeve wants to merge 1 commit into
Open
Conversation
The completion menu stays active while the user types past it, and any Enter/Submit/SubmitOrNewline while a menu is active is routed to the menu. A menu whose filtered suggestions are empty has nothing to accept, so the keypress simply died: the line did not run and nothing visibly happened, leaving Enter to work only on the second press. The guard now ignores active menus with no values, so the event falls through to the normal submit path, and submit_buffer closes any menu that let a submit through so it cannot stay active into the next line's editing.
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.
The symptom
With a completion menu registered, Enter sometimes appears dead: the line doesn't run, nothing is inserted, and a second Enter is needed. Repro:
The mechanism
The menu stays active from the first Tab until Esc/Enter/empty-buffer, and the
Enter | Submit | SubmitOrNewlinearm consumes the event for any active menu — including one with zero filtered values, wherereplace_in_bufferhas nothing to accept. The keypress is spent deactivating an invisible menu.The change
submit_bufferdeactivates menus, so a menu that let a submit through can't stay active into the next line's editing.Two tests: the empty-menu case directly, and the full reported shape (Tab mid-line, type on, Enter runs the line).
cargo fmt --all,cargo clippy --locked --all-targets --all-features(0 warnings), and the test suite pass; the pre-existing macOS-only parallel flake in the system-clipboard tests is unrelated.Found while building a SQL REPL on reedline (duckdb-harbor's pilot), where a stale menu turned end-of-statement Enters into no-ops. Diagnosed and written with AI assistance; verified by the suite here and by daily use downstream.