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.

Windows: Fix files opened by UNC path getting no language servers (#56553)

Joblena51d23c93d15
diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs
index 9e80bf1d609..42133b3df3e 100644
--- a/crates/util/src/paths.rs
+++ b/crates/util/src/paths.rs
@@ -258,6 +258,10 @@ impl SanitizedPath {
#[cfg(target_os = "windows")]
{
+ let path = match path.to_str().and_then(|s| s.strip_prefix(r"\\?\UNC\")) {
+ Some(rest) => PathBuf::from(format!(r"\\{rest}")).into(),
+ None => path,
+ };
let simplified = dunce::simplified(path.as_ref());
if simplified == path.as_ref() {
// safe because `Path` and `SanitizedPath` have the same repr and Drop impl
@@ -2741,6 +2745,14 @@ mod tests {
);
}
+ #[perf]
+ #[cfg(target_os = "windows")]
+ fn test_sanitized_path_verbatim_unc() {
+ let path: Arc<Path> = PathBuf::from("\\\\?\\UNC\\server\\share\\file.txt").into();
+ let sanitized_path = SanitizedPath::from_arc(path);
+ assert_eq!(sanitized_path.to_string(), "\\\\server\\share\\file.txt");
+ }
+
#[perf]
fn test_compare_numeric_segments() {
// Helper function to create peekable iterators and test