mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
fix cli welcome screen (#13474)
Release Notes: - Fixed first launch via cli --------- Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
c6c5907693
commit
8949460bd7
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2223,6 +2223,7 @@ dependencies = [
|
|||||||
"fork",
|
"fork",
|
||||||
"ipc-channel",
|
"ipc-channel",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"parking_lot",
|
||||||
"paths",
|
"paths",
|
||||||
"plist",
|
"plist",
|
||||||
"release_channel",
|
"release_channel",
|
||||||
|
@ -21,6 +21,7 @@ anyhow.workspace = true
|
|||||||
clap.workspace = true
|
clap.workspace = true
|
||||||
ipc-channel = "0.18"
|
ipc-channel = "0.18"
|
||||||
once_cell.workspace = true
|
once_cell.workspace = true
|
||||||
|
parking_lot.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
release_channel.workspace = true
|
release_channel.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cli::{ipc::IpcOneShotServer, CliRequest, CliResponse, IpcHandshake};
|
use cli::{ipc::IpcOneShotServer, CliRequest, CliResponse, IpcHandshake};
|
||||||
|
use parking_lot::Mutex;
|
||||||
use std::{
|
use std::{
|
||||||
env, fs, io,
|
env, fs, io,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::ExitStatus,
|
process::ExitStatus,
|
||||||
|
sync::Arc,
|
||||||
thread::{self, JoinHandle},
|
thread::{self, JoinHandle},
|
||||||
};
|
};
|
||||||
use util::paths::PathLikeWithPosition;
|
use util::paths::PathLikeWithPosition;
|
||||||
@ -123,7 +125,11 @@ fn main() -> Result<()> {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let sender: JoinHandle<anyhow::Result<()>> = thread::spawn(move || {
|
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 (_, handshake) = server.accept().context("Handshake after Zed spawn")?;
|
||||||
let (tx, rx) = (handshake.requests, handshake.responses);
|
let (tx, rx) = (handshake.requests, handshake.responses);
|
||||||
tx.send(CliRequest::Open {
|
tx.send(CliRequest::Open {
|
||||||
@ -138,11 +144,15 @@ fn main() -> Result<()> {
|
|||||||
CliResponse::Ping => {}
|
CliResponse::Ping => {}
|
||||||
CliResponse::Stdout { message } => println!("{message}"),
|
CliResponse::Stdout { message } => println!("{message}"),
|
||||||
CliResponse::Stderr { message } => eprintln!("{message}"),
|
CliResponse::Stderr { message } => eprintln!("{message}"),
|
||||||
CliResponse::Exit { status } => std::process::exit(status),
|
CliResponse::Exit { status } => {
|
||||||
|
exit_status.lock().replace(status);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if args.foreground {
|
if args.foreground {
|
||||||
@ -152,6 +162,9 @@ fn main() -> Result<()> {
|
|||||||
sender.join().unwrap()?;
|
sender.join().unwrap()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(exit_status) = exit_status.lock().take() {
|
||||||
|
std::process::exit(exit_status);
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,8 @@ pub async fn handle_cli_connection(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
|
} 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 {
|
} else {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
workspace::open_new(app_state, cx, |workspace, cx| {
|
workspace::open_new(app_state, cx, |workspace, cx| {
|
||||||
|
Loading…
Reference in New Issue
Block a user