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.
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::Editarm, beside the existing empty-buffer deactivation):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_menusalready reads like the natural gate), whichever fits reedline's intent for menu lifetime.