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: Add extra paths in `detect()` on Windows (#25765)

Maksim Bondarenkova8a05f208bea
diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs
index b74a72b63cb..bf87ec92d30 100644
--- a/crates/cli/src/main.rs
+++ b/crates/cli/src/main.rs
@@ -614,12 +614,19 @@ mod windows {
let path = if let Some(path) = path {
path.to_path_buf().canonicalize()?
} else {
- std::env::current_exe()?
- .parent()
- .context("no parent path for cli")?
- .parent()
- .context("no parent path for cli folder")?
- .join("Zed.exe")
+ let cli = std::env::current_exe()?;
+ let dir = cli.parent().context("no parent path for cli")?;
+
+ // ../Zed.exe is the standard, lib/zed is for MSYS2, ./zed.exe is for the target
+ // directory in development builds.
+ let possible_locations = ["../Zed.exe", "../lib/zed/zed-editor.exe", "./zed.exe"];
+ possible_locations
+ .iter()
+ .find_map(|p| dir.join(p).canonicalize().ok().filter(|path| path != &cli))
+ .context(format!(
+ "could not find any of: {}",
+ possible_locations.join(", ")
+ ))?
};
Ok(App(path))