Focus command mode from shortcut
This commit is contained in:
@@ -6,8 +6,8 @@ use gpui::{App, AppContext, Context, Entity, FocusHandle, Focusable, Subscriptio
|
||||
use gpui_component::input::{InputEvent, InputState, SelectAll};
|
||||
|
||||
use crate::{
|
||||
CloseCurrentTab, FocusAddressBar, OpenDownloads, OpenNewTab, RestoreClosedTab, SelectNextTab,
|
||||
SelectPreviousTab, ToggleFavoriteTab, TogglePinnedTab,
|
||||
CloseCurrentTab, FocusAddressBar, FocusCommandMode, OpenDownloads, OpenNewTab,
|
||||
RestoreClosedTab, SelectNextTab, SelectPreviousTab, ToggleFavoriteTab, TogglePinnedTab,
|
||||
};
|
||||
|
||||
enum ShellState {
|
||||
@@ -108,6 +108,18 @@ impl ElyShell {
|
||||
window.dispatch_action(Box::new(SelectAll), cx);
|
||||
}
|
||||
|
||||
fn focus_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_input.update(cx, |input, cx| {
|
||||
input.set_value(">", window, cx);
|
||||
input.focus(window, cx);
|
||||
});
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn select_tab(&mut self, tab_id: &TabId, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if let ShellState::Ready(core) = &mut self.state
|
||||
&& core.select_tab(tab_id).is_ok()
|
||||
@@ -210,6 +222,15 @@ impl ElyShell {
|
||||
self.focus_address_bar(window, cx);
|
||||
}
|
||||
|
||||
fn on_focus_command_mode(
|
||||
&mut self,
|
||||
_: &FocusCommandMode,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.focus_command_mode(window, cx);
|
||||
}
|
||||
|
||||
fn on_open_new_tab(&mut self, _: &OpenNewTab, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.open_new_tab(window, cx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user