fix(command): close the command overlay on Escape
This commit is contained in:
@@ -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<Self>) {
|
||||||
|
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 {
|
impl Focusable for ElyShell {
|
||||||
|
|||||||
@@ -259,6 +259,11 @@ impl ElyShell {
|
|||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
let key = event.keystroke.key.as_str();
|
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") {
|
if !matches!(key, "up" | "down" | "enter") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user