Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

cli: Defer app activation until after open-behavior prompt (#53915)

Eric Holk11edacfd0f8a
diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs
index 49129532603..520f6e6cf2e 100644
--- a/crates/cli/src/main.rs
+++ b/crates/cli/src/main.rs
@@ -1217,7 +1217,9 @@ mod mac_os {
string::kCFStringEncodingUTF8,
url::{CFURL, CFURLCreateWithBytes},
};
- use core_services::{LSLaunchURLSpec, LSOpenFromURLSpec, kLSLaunchDefaults};
+ use core_services::{
+ LSLaunchURLSpec, LSOpenFromURLSpec, kLSLaunchDefaults, kLSLaunchDontSwitch,
+ };
use serde::Deserialize;
use std::{
ffi::OsStr,
@@ -1316,7 +1318,7 @@ mod mac_os {
appURL: app_url.as_concrete_TypeRef(),
itemURLs: urls_to_open.as_concrete_TypeRef(),
passThruParams: ptr::null(),
- launchFlags: kLSLaunchDefaults,
+ launchFlags: kLSLaunchDefaults | kLSLaunchDontSwitch,
asyncRefCon: ptr::null_mut(),
},
ptr::null_mut(),
diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rs
index e1a98e62a0f..aa55ef54380 100644
--- a/crates/zed/src/zed/open_listener.rs
+++ b/crates/zed/src/zed/open_listener.rs
@@ -482,6 +482,7 @@ pub async fn handle_cli_connection(
cx,
) {
Ok(open_request) => {
+ cx.activate(true);
handle_open_request(open_request, app_state.clone(), cx);
responses.send(CliResponse::Exit { status: 0 }).log_err();
}
@@ -518,6 +519,8 @@ pub async fn handle_cli_connection(
}
}
+ cx.update(|cx| cx.activate(true));
+
let open_workspace_result = open_workspaces(
paths,
diff_paths,