Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make `dispatch_global_action` private
Antonio Scandurra029538fe2157
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rsindex c201febed5a..a949b64c04a 100644--- a/crates/gpui/src/app.rs+++ b/crates/gpui/src/app.rs@@ -1048,7 +1048,7 @@ impl AppContext {}}- pub fn dispatch_global_action<A: Action>(&mut self, action: A) {+ fn dispatch_global_action<A: Action>(&mut self, action: A) {self.dispatch_global_action_any(&action);}diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex 2724e8587f3..58a53b9e402 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -29,8 +29,16 @@ use settings::{use simplelog::ConfigBuilder;use smol::process::Command;use std::{- env, ffi::OsStr, fs::OpenOptions, io::Write as _, os::unix::prelude::OsStrExt, panic,- path::PathBuf, sync::Arc, thread, time::Duration,+ env,+ ffi::OsStr,+ fs::OpenOptions,+ io::Write as _,+ os::unix::prelude::OsStrExt,+ panic,+ path::PathBuf,+ sync::{Arc, Weak},+ thread,+ time::Duration,};use terminal_view::{get_working_directory, TerminalView};use util::http::{self, HttpClient};@@ -104,7 +112,13 @@ fn main() {.log_err();}})- .on_reopen(move |cx| cx.dispatch_global_action(NewFile));+ .on_reopen(move |cx| {+ if cx.has_global::<Weak<AppState>>() {+ if let Some(app_state) = cx.global::<Weak<AppState>>().upgrade() {+ workspace::open_new(&app_state, cx, |_, cx| cx.dispatch_action(NewFile)).detach();+ }+ }+ });app.run(move |cx| {cx.set_global(*RELEASE_CHANNEL);@@ -190,6 +204,7 @@ fn main() {dock_default_item_factory,background_actions,});+ cx.set_global(Arc::downgrade(&app_state));auto_update::init(http, client::ZED_SERVER_URL.clone(), cx);workspace::init(app_state.clone(), cx);@@ -274,7 +289,7 @@ async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppcx.update(|cx| show_welcome_experience(app_state, cx));} else {cx.update(|cx| {- cx.dispatch_global_action(NewFile);+ workspace::open_new(app_state, cx, |_, cx| cx.dispatch_action(NewFile)).detach();});}}