Completion menu stays active for the rest of the line once opened
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 818
- Forks
- 249
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 30
Description
Once Tab opens the completion menu, it stays active until Esc, Enter, or an empty buffer — typing past the completed word keeps it alive, refiltering against whatever word the cursor lands in later. Combined with Enter-while-menu-active being routed to the menu, a Tab pressed early in a line can intercept an Enter pressed much later: instead of the line running, the menu's highlighted suggestion is inserted at the end of the line. (#1175 fixes the empty-menu half of this; this issue is about the non-empty half.)
Concrete shape, from a SQL REPL built on reedline: type create or replace ta, Tab (menu opens), type the rest of the statement, Enter — a stray keyword is appended at the cursor instead of the statement submitting.
Proposal: typing a word-boundary character (whitespace at minimum) deactivates the menu, the way fish/zsh close their completion pagers on space. The completion the menu was opened for is over once the word it was filtering ends; a menu that lingers past that point mostly exists to intercept keys the user meant for the line.
Sketch (in the ReedlineEvent::Edit arm, beside the existing empty-buffer deactivation):
let word_boundary = matches!(commands.first(),
Some(EditCommand::InsertChar(c)) if c.is_whitespace());
if !self.persistent_menus && (word_boundary || buffer_is_empty) {
menu.menu_event(MenuEvent::Deactivate);
}
We run this downstream (with a test: open menu on th, insert a space, menu is inactive) and it reads well in daily use — happy to PR it as-is or behind an option (persistent_menus already reads like the natural gate), whichever fits reedline's intent for menu lifetime.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the ReedlineEvent::Edit arm beside the existing empty-buffer deactivation, and review how menu events are handled when a whitespace InsertChar arrives. Reproduce the SQL REPL sequence or the described test: open the menu on th, insert a space, and verify the menu is inactive so a later Enter submits the line rather than inserting a suggestion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100