fix(command): submit typed command on Enter without focusing the input (#99)

Unfocused keyboard input routes through the global subscription: typed
characters reach the command line, but Enter went to CommandFinalize, which
only forwarded the buffer to CommandSubmit while a command was already active.
At startup (before the window grabs focus) typing a command name and pressing
Enter did nothing until the user clicked into the command line. Forward any
non-empty buffer to CommandSubmit regardless of active-command state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-15 00:35:03 +03:00
commit 036ac7dd86

View file

@ -1376,13 +1376,16 @@ impl OpenCADStudio {
let idx = self.grip_popup.as_ref().map(|p| p.selected).unwrap_or(0); let idx = self.grip_popup.as_ref().map(|p| p.selected).unwrap_or(0);
return Task::done(Message::GripMenuPick(idx)); return Task::done(Message::GripMenuPick(idx));
} }
// Pending typed command-line text (e.g. an option keyword like // Any typed command-line text must be submitted rather than
// "R") must be submitted rather than finalising the command. // finalising. The focused-input Enter routes through
// The focused-input Enter routes through CommandSubmit, but a // CommandSubmit, but when the field isn't focused — e.g. at
// command started from the ribbon never focuses the field, so // startup before the window grabs focus, or a command started
// its Enter arrives here — forward to the same submit path. // from the ribbon — its Enter arrives here. Forward a non-empty
// buffer to the same submit path so typing a command name (or
// an option keyword like "R") and pressing Enter works without
// first clicking into the command line (issue #99).
let i = self.active_tab; let i = self.active_tab;
if self.tabs[i].active_cmd.is_some() && !self.command_line.input.trim().is_empty() { if !self.command_line.input.trim().is_empty() {
return self.update(Message::CommandSubmit); return self.update(Message::CommandSubmit);
} }
// A typed dynamic-input value commits as a point pick // A typed dynamic-input value commits as a point pick