Return focus to the workspace center on escape

This commit is contained in:
Max Brunsfeld 2022-06-16 11:30:02 -07:00
parent cef85f5d84
commit dd7b874039
4 changed files with 19 additions and 2 deletions

View file

@ -186,6 +186,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
);
cx.add_action(Workspace::toggle_sidebar_item);
cx.add_action(Workspace::toggle_sidebar_item_focus);
cx.add_action(Workspace::focus_center);
cx.add_action(|workspace: &mut Workspace, _: &ActivatePreviousPane, cx| {
workspace.activate_previous_pane(cx)
});
@ -1281,6 +1282,11 @@ impl Workspace {
cx.notify();
}
pub fn focus_center(&mut self, _: &menu::Cancel, cx: &mut ViewContext<Self>) {
cx.focus_self();
cx.notify();
}
fn add_pane(&mut self, cx: &mut ViewContext<Self>) -> ViewHandle<Pane> {
let pane = cx.add_view(|cx| Pane::new(cx));
let pane_id = pane.id();