From 3a0465773050d0ce8319cc4a2276f688d72e7635 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 12 Aug 2025 14:24:25 -0400 Subject: [PATCH] emmet: Add workaround for leading `/` on Windows paths (#36064) This PR adds a workaround for the leading `/` on Windows paths (https://github.com/zed-industries/zed/issues/20559). Release Notes: - N/A --- extensions/emmet/src/emmet.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/extensions/emmet/src/emmet.rs b/extensions/emmet/src/emmet.rs index 83fe809c34..e4fb3cf814 100644 --- a/extensions/emmet/src/emmet.rs +++ b/extensions/emmet/src/emmet.rs @@ -70,8 +70,7 @@ impl zed::Extension for EmmetExtension { Ok(zed::Command { command: zed::node_binary_path()?, args: vec![ - env::current_dir() - .unwrap() + zed_ext::sanitize_windows_path(env::current_dir().unwrap()) .join(&server_path) .to_string_lossy() .to_string(), @@ -83,3 +82,25 @@ impl zed::Extension for EmmetExtension { } zed::register_extension!(EmmetExtension); + +/// Extensions to the Zed extension API that have not yet stabilized. +mod zed_ext { + /// Sanitizes the given path to remove the leading `/` on Windows. + /// + /// On macOS and Linux this is a no-op. + /// + /// This is a workaround for https://github.com/bytecodealliance/wasmtime/issues/10415. + pub fn sanitize_windows_path(path: std::path::PathBuf) -> std::path::PathBuf { + use zed_extension_api::{Os, current_platform}; + + let (os, _arch) = current_platform(); + match os { + Os::Mac | Os::Linux => path, + Os::Windows => path + .to_string_lossy() + .to_string() + .trim_start_matches('/') + .into(), + } + } +}