From 4a2132bc91e3c342ae7da10523ea486deb4a334d Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 27 Mar 2023 16:05:00 -0700 Subject: [PATCH] Make 'new file' action open a window when there are no windows open --- crates/workspace/src/workspace.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index f752e6d2b6..fe60065486 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -258,6 +258,14 @@ pub fn init(app_state: Arc, cx: &mut MutableAppContext) { } } }); + cx.add_global_action({ + let app_state = Arc::downgrade(&app_state); + move |_: &NewFile, cx: &mut MutableAppContext| { + if let Some(app_state) = app_state.upgrade() { + open_new(&app_state, cx, |_, cx| cx.dispatch_action(NewFile)).detach(); + } + } + }); cx.add_async_action(Workspace::toggle_follow); cx.add_async_action(Workspace::follow_next_collaborator);