Preserve --user-data-dir across restarts (#62022)
# Objective Fixes #57701. When Zed is launched with `--user-data-dir`, a Zed-initiated restart—such as `workspace: clear trusted worktrees` or Restart to Update—can relaunch Zed without that argument. The restarted process then uses the default data directory instead of the directory selected by the user. ## Solution - Store the resolved custom data directory as GPUI restart arguments alongside the existing optional restart executable path. - Forward those arguments when relaunching on Linux, macOS, and Windows. - Preserve argument boundaries and native `OsString` values, including paths containing spaces. - On Windows updates, carry the arguments through `auto_update_helper.exe` when it launches the updated `Zed.exe`. Normal launches without `--user-data-dir` continue to restart without additional arguments. This does not attempt to preserve unrelated CLI arguments or general launch state. ## Testing - `cargo fmt --all -- --check` - `cargo test -p gpui` - `cargo test -p auto_update --features workspace/test-support` - `cargo check -p auto_update_helper --tests --target x86_64-pc-windows-msvc` - `./script/clippy -p gpui -p gpui_macos -p auto_update -p zed` - `./script/clippy -p auto_update_helper --target x86_64-pc-windows-msvc` The regression tests cover simultaneous restart executable and argument forwarding, Windows paths containing spaces and trailing backslashes, updater-helper argument parsing, and the final `Zed.exe` command. Compilation and unit tests were run on macOS. Linux and Windows runtime behavior was reviewed but not run locally. A full `gpui_windows` cross-target check was attempted, but its `psm` dependency requires the MSVC `lib.exe` tool, which is not available on this macOS host; the standalone Windows updater helper and its tests compile successfully for the Windows target. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards (no UI changes) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed Zed forgetting an explicitly passed `--user-data-dir` argument after restarting (e.g. clicking "Restart to Update") --------- Co-authored-by: Tom Houlé <tom@tomhoule.com>
This commit is contained in:
1 parent
2dd39da2b0
commit
d7f85eed4e
13 files changed
+243
-62
No files matched your search
@@ -285,7 +285,7 @@ impl<P: LinuxClient + 'static> Platform for LinuxPlatform<P> {
|
||||
self.inner.compositor_name()
|
||||
}
|
||||
|
||||
fn restart(&self, binary_path: Option<PathBuf>) {
|
||||
fn restart(&self, binary_path: Option<PathBuf>, arguments: Vec<std::ffi::OsString>) {
|
||||
use std::os::unix::process::CommandExt as _;
|
||||
|
||||
// get the process id of the current process
|
||||
@@ -312,7 +312,9 @@ impl<P: LinuxClient + 'static> Platform for LinuxPlatform<P> {
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
"$1"
|
||||
app_path="$1"
|
||||
shift
|
||||
"$app_path" "$@"
|
||||
"#;
|
||||
|
||||
#[allow(
|
||||
@@ -325,6 +327,7 @@ impl<P: LinuxClient + 'static> Platform for LinuxPlatform<P> {
|
||||
.arg(script)
|
||||
.arg(&app_pid)
|
||||
.arg(&app_path)
|
||||
.args(arguments)
|
||||
.process_group(0)
|
||||
.spawn();
|
||||
|
||||
|
||||
Reference in new issue
Block a user