Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
fix cli welcome screen (#13474)
Conrad Irwin8949460bd7f1
diff --git a/Cargo.lock b/Cargo.lockindex 58843a2bfa6..04871af1148 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2223,6 +2223,7 @@ dependencies = ["fork","ipc-channel","once_cell",+ "parking_lot","paths","plist","release_channel",diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.tomlindex ae58f7c641b..aa64e8de8f8 100644--- a/crates/cli/Cargo.toml+++ b/crates/cli/Cargo.toml@@ -21,6 +21,7 @@ anyhow.workspace = trueclap.workspace = trueipc-channel = "0.18"once_cell.workspace = true+parking_lot.workspace = truepaths.workspace = truerelease_channel.workspace = trueserde.workspace = truediff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rsindex 8c8da80a5ca..482f590dfc3 100644--- a/crates/cli/src/main.rs+++ b/crates/cli/src/main.rs@@ -3,10 +3,12 @@use anyhow::{Context, Result};use clap::Parser;use cli::{ipc::IpcOneShotServer, CliRequest, CliResponse, IpcHandshake};+use parking_lot::Mutex;use std::{env, fs, io,path::{Path, PathBuf},process::ExitStatus,+ sync::Arc,thread::{self, JoinHandle},};use util::paths::PathLikeWithPosition;@@ -123,26 +125,34 @@ fn main() -> Result<()> {None};- let sender: JoinHandle<anyhow::Result<()>> = thread::spawn(move || {- let (_, handshake) = server.accept().context("Handshake after Zed spawn")?;- let (tx, rx) = (handshake.requests, handshake.responses);- tx.send(CliRequest::Open {- paths,- wait: args.wait,- open_new_workspace,- dev_server_token: args.dev_server_token,- })?;-- while let Ok(response) = rx.recv() {- match response {- CliResponse::Ping => {}- CliResponse::Stdout { message } => println!("{message}"),- CliResponse::Stderr { message } => eprintln!("{message}"),- CliResponse::Exit { status } => std::process::exit(status),+ let exit_status = Arc::new(Mutex::new(None));++ let sender: JoinHandle<anyhow::Result<()>> = thread::spawn({+ let exit_status = exit_status.clone();+ move || {+ let (_, handshake) = server.accept().context("Handshake after Zed spawn")?;+ let (tx, rx) = (handshake.requests, handshake.responses);+ tx.send(CliRequest::Open {+ paths,+ wait: args.wait,+ open_new_workspace,+ dev_server_token: args.dev_server_token,+ })?;++ while let Ok(response) = rx.recv() {+ match response {+ CliResponse::Ping => {}+ CliResponse::Stdout { message } => println!("{message}"),+ CliResponse::Stderr { message } => eprintln!("{message}"),+ CliResponse::Exit { status } => {+ exit_status.lock().replace(status);+ return Ok(());+ }+ }}- }- Ok(())+ Ok(())+ }});if args.foreground {@@ -152,6 +162,9 @@ fn main() -> Result<()> {sender.join().unwrap()?;}+ if let Some(exit_status) = exit_status.lock().take() {+ std::process::exit(exit_status);+ }Ok(())}diff --git a/crates/zed/src/zed/open_listener.rs b/crates/zed/src/zed/open_listener.rsindex d9b46675d10..6a1ac96095e 100644--- a/crates/zed/src/zed/open_listener.rs+++ b/crates/zed/src/zed/open_listener.rs@@ -398,7 +398,8 @@ pub async fn handle_cli_connection(}}} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {- cx.update(|cx| show_welcome_view(app_state, cx)).log_err();+ cx.update(|cx| show_welcome_view(app_state, cx).detach())+ .log_err();} else {cx.update(|cx| {workspace::open_new(app_state, cx, |workspace, cx| {