Fix Node.js language servers failing with --user-data-dir on Windows (#50767)
Closes #50677. Release Notes: - Fixed Node.js language servers failing with `--user-data-dir` on Windows
This commit is contained in:
1 parent
16f4fcbb70
commit
9ff7546db1
1 file changed
+9
-2
@@ -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()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user