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.

Fix Node.js language servers failing with `--user-data-dir` on Windows (#50767)

Kunall Banerjeeeb6e7d7b6489
diff --git a/crates/paths/src/paths.rs b/crates/paths/src/paths.rs
index c9b9c756217..7afab7e8169 100644
--- a/crates/paths/src/paths.rs
+++ b/crates/paths/src/paths.rs
@@ -4,6 +4,7 @@ use std::env;
use std::path::{Path, PathBuf};
use std::sync::{LazyLock, OnceLock};
+use util::paths::SanitizedPath;
pub use util::paths::home_dir;
use util::rel_path::RelPath;
@@ -71,8 +72,14 @@ pub fn set_custom_data_dir(dir: &str) -> &'static PathBuf {
CUSTOM_DATA_DIR.get_or_init(|| {
let path = PathBuf::from(dir);
std::fs::create_dir_all(&path).expect("failed to create custom data directory");
- path.canonicalize()
- .expect("failed to canonicalize custom data directory's path to an absolute path")
+ let canonicalized = path
+ .canonicalize()
+ .expect("failed to canonicalize custom data directory's path to an absolute path");
+ // On Windows, `canonicalize` produces extended-length paths prefixed
+ // with `\\?\`. Strip that prefix so downstream consumers (e.g.
+ // Node.js language servers) that receive derived paths as arguments
+ // don't choke on the verbatim syntax.
+ SanitizedPath::new(&canonicalized).as_path().to_path_buf()
})
}