Skip to content

Commit 0d83858

Browse files
echobtfactorydroid
andauthored
fix(tui): only show help menu on '?' when input is empty (#494)
Previously, pressing '?' would always open the help menu regardless of whether there was text in the input field. This made it impossible to type the '?' character when composing prompts. Now, pressing '?' will: - Open the help menu if the input is empty - Type '?' into the input if there is existing text This allows French keyboard users and others to type '?' while still providing quick access to help when the prompt is empty. Co-authored-by: Droid Agent <droid@factory.ai>
1 parent 6e011bc commit 0d83858

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cortex-tui/src/runner/event_loop.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,21 @@ impl EventLoop {
19521952
return Ok(());
19531953
}
19541954

1955+
// Handle '?' key specially: only show help when input is empty
1956+
// Otherwise, type '?' into the input
1957+
if action == KeyAction::Help
1958+
&& key_event.code == KeyCode::Char('?')
1959+
&& context == ActionContext::Input
1960+
&& !self.app_state.input.is_empty()
1961+
{
1962+
// Type '?' into the input instead of opening help
1963+
self.app_state.text_selection.clear();
1964+
self.app_state.input.handle_key(key_event);
1965+
self.update_autocomplete();
1966+
self.render(terminal)?;
1967+
return Ok(());
1968+
}
1969+
19551970
// Forward key events to input widget when focused and no action mapped
19561971
// This allows character input, backspace, delete, etc. to work
19571972
if context == ActionContext::Input && action == KeyAction::None {

0 commit comments

Comments
 (0)