From 702e618bbaf4f8b5865020b71731c5d7510974bd Mon Sep 17 00:00:00 2001 From: localcc Date: Thu, 2 Oct 2025 15:20:48 +0200 Subject: [PATCH] Fix local to WSL path conversion (#39301) Release Notes: - N/A --- crates/util/src/paths.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index 38e8b8459718e238374f33d7cc7d0c9feb31aabb..f9fe0ab33da2dc97b7bb59f9a0c109d0f96a4536 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -103,7 +103,9 @@ impl> PathExt for T { /// Converts a local path to one that can be used inside of WSL. /// Returns `None` if the path cannot be converted into a WSL one (network share). fn local_to_wsl(&self) -> Option { - let mut new_path = PathBuf::new(); + // quite sketchy to convert this back to path at the end, but a lot of functions only accept paths + // todo: ideally rework them..? + let mut new_path = std::ffi::OsString::new(); for component in self.as_ref().components() { match component { std::path::Component::Prefix(prefix) => { @@ -113,11 +115,20 @@ impl> PathExt for T { new_path.push(format!("/mnt/{}", drive_letter)); } std::path::Component::RootDir => {} - _ => new_path.push(component), + std::path::Component::CurDir => { + new_path.push("/."); + } + std::path::Component::ParentDir => { + new_path.push("/.."); + } + std::path::Component::Normal(os_str) => { + new_path.push("/"); + new_path.push(os_str); + } } } - Some(new_path) + Some(new_path.into()) } }