diff --git a/crates/ely_app/src/shell/focus.rs b/crates/ely_app/src/shell/focus.rs index 0b1d26d..5c99a33 100644 --- a/crates/ely_app/src/shell/focus.rs +++ b/crates/ely_app/src/shell/focus.rs @@ -15,6 +15,18 @@ impl ElyShell { }); } } + + /// Close the command overlay (Escape or a backdrop click): drop the + /// `>` query that drives its visibility, reset the selection, and put + /// the active tab's address back in the omnibar. + pub(super) fn exit_command_mode(&mut self, window: &mut Window, cx: &mut Context) { + if let ShellState::Ready(core) = &mut self.state { + core.set_command_query(""); + } + self.command_selected_index = 0; + self.sync_address_input(window, cx); + cx.notify(); + } } impl Focusable for ElyShell { diff --git a/crates/ely_app/src/shell/render.rs b/crates/ely_app/src/shell/render.rs index cd3fb52..ca26f4d 100644 --- a/crates/ely_app/src/shell/render.rs +++ b/crates/ely_app/src/shell/render.rs @@ -259,6 +259,11 @@ impl ElyShell { cx: &mut Context, ) { let key = event.keystroke.key.as_str(); + if key == "escape" { + self.exit_command_mode(window, cx); + cx.stop_propagation(); + return; + } if !matches!(key, "up" | "down" | "enter") { return; }