Skip to content

Don't let a menu with no suggestions swallow Enter - #1175

Open
shreeve wants to merge 1 commit into
nushell:mainfrom
shreeve:menu-must-not-swallow-enter
Open

Don't let a menu with no suggestions swallow Enter#1175
shreeve wants to merge 1 commit into
nushell:mainfrom
shreeve:menu-must-not-swallow-enter

Conversation

@shreeve

@shreeve shreeve commented Aug 19, 2026

Copy link
Copy Markdown

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:

  1. Type a word with matches, press Tab — the menu opens.
  2. Keep typing until the word under the cursor matches nothing (the menu shows "NO RECORDS FOUND" — or the user has long since scrolled on and can't see it).
  3. Press Enter.

The mechanism

The menu stays active from the first Tab until Esc/Enter/empty-buffer, and the Enter | Submit | SubmitOrNewline arm consumes the event for any active menu — including one with zero filtered values, where replace_in_buffer has nothing to accept. The keypress is spent deactivating an invisible menu.

The change

  • The arm's guard now ignores active menus whose values are empty, so the event falls through to the normal submit path.
  • submit_buffer deactivates 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.

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.
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.

1 participant