Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ crate-type = ["cdylib"]

[dependencies]
serde = { version = "1.0", features = ["derive"] }
zed_extension_api = "0.4.0"
zed_extension_api = "0.7.0"
28 changes: 4 additions & 24 deletions src/vue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ impl VueExtension {
println!("typescript already installed");
}

self.typescript_tsdk_path = zed_ext::sanitize_windows_path(env::current_dir().unwrap())
self.typescript_tsdk_path = env::current_dir()
.unwrap()
.join(TYPESCRIPT_TSDK_PATH)
.to_string_lossy()
.to_string();
Expand Down Expand Up @@ -182,7 +183,8 @@ impl zed::Extension for VueExtension {
Ok(zed::Command {
command: zed::node_binary_path()?,
args: vec![
zed_ext::sanitize_windows_path(env::current_dir().unwrap())
env::current_dir()
.unwrap()
.join(&server_path)
.to_string_lossy()
.to_string(),
Expand Down Expand Up @@ -292,25 +294,3 @@ impl zed::Extension for VueExtension {
}

zed::register_extension!(VueExtension);

/// 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::{current_platform, Os};

let (os, _arch) = current_platform();
match os {
Os::Mac | Os::Linux => path,
Os::Windows => path
.to_string_lossy()
.to_string()
.trim_start_matches('/')
.into(),
}
}
}