From f23096034b35e9520e2799bc274d9f08d1426bcc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 2 Sep 2025 20:49:04 -0700 Subject: [PATCH] Remove wsl command line args on non-windows platforms (#37422) Release Notes: - N/A --- crates/cli/src/main.rs | 15 +++++++++++++-- crates/zed/src/main.rs | 8 +++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index d67843b4c93eb64b01fbdd6e26955d96a0c50e70..d4b4a350f61b5bd1249b33ff3925dd281e9d529c 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -93,6 +93,7 @@ struct Args { /// Example: `me@Ubuntu` or `Ubuntu`. /// /// WARN: You should not fill in this field by hand. + #[cfg(target_os = "windows")] #[arg(long, value_name = "USER@DISTRO")] wsl: Option, /// Not supported in Zed CLI, only supported on Zed binary @@ -303,6 +304,11 @@ fn main() -> Result<()> { ]); } + #[cfg(target_os = "windows")] + let wsl = args.wsl.as_ref(); + #[cfg(not(target_os = "windows"))] + let wsl = None; + for path in args.paths_with_position.iter() { if path.starts_with("zed://") || path.starts_with("http://") @@ -321,7 +327,7 @@ fn main() -> Result<()> { paths.push(tmp_file.path().to_string_lossy().to_string()); let (tmp_file, _) = tmp_file.keep()?; anonymous_fd_tmp_files.push((file, tmp_file)); - } else if let Some(wsl) = &args.wsl { + } else if let Some(wsl) = wsl { urls.push(format!("file://{}", parse_path_in_wsl(path, wsl)?)); } else { paths.push(parse_path_with_position(path)?); @@ -340,11 +346,16 @@ fn main() -> Result<()> { let (_, handshake) = server.accept().context("Handshake after Zed spawn")?; let (tx, rx) = (handshake.requests, handshake.responses); + #[cfg(target_os = "windows")] + let wsl = args.wsl; + #[cfg(not(target_os = "windows"))] + let wsl = None; + tx.send(CliRequest::Open { paths, urls, diff_paths, - wsl: args.wsl, + wsl, wait: args.wait, open_new_workspace, env, diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 3a7baa1559d68cbce8cfbf96b0bf4384aa1f7e0b..52e475edf8620a1ce97ce732f12777d9bb0cad1a 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -707,11 +707,16 @@ pub fn main() { .map(|chunk| [chunk[0].clone(), chunk[1].clone()]) .collect(); + #[cfg(target_os = "windows")] + let wsl = args.wsl; + #[cfg(not(target_os = "windows"))] + let wsl = None; + if !urls.is_empty() || !diff_paths.is_empty() { open_listener.open(RawOpenRequest { urls, diff_paths, - wsl: args.wsl, + wsl, }) } @@ -1192,6 +1197,7 @@ struct Args { /// Example: `me@Ubuntu` or `Ubuntu`. /// /// WARN: You should not fill in this field by hand. + #[cfg(target_os = "windows")] #[arg(long, value_name = "USER@DISTRO")] wsl: Option,