From 36210e72af5e5c480775ddd83e9d31afec1cc52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Mon, 20 Oct 2025 11:46:34 +0200 Subject: [PATCH] Make the Yarn SDK path relative to the worktree (#40062) Let's say you run this: ``` cd ~/proj-a zed ~/proj-b ``` The `zed` process will execute with `current_dir() = ~/proj-a`, but a `worktree_root_path() = ~/proj-b`. The old detection was then checking if the Yarn SDK was installed in `proj-a` to decide whether to set the tsdk value or not. This was incorrect, as we should instead check for the SDK presence inside `proj-b`. Release Notes: - Fixed the Yarn SDK detection when the Zed pwd is different from the opened folder. --- crates/languages/src/vtsls.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/languages/src/vtsls.rs b/crates/languages/src/vtsls.rs index fbaab1341c3b5332887698f0e28397a15b9f158b..8cbb9f307f6f4222e0e9a65fe2a6954f97fc7f21 100644 --- a/crates/languages/src/vtsls.rs +++ b/crates/languages/src/vtsls.rs @@ -12,7 +12,7 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use util::{ResultExt, maybe, merge_json_value_into, rel_path::RelPath}; +use util::{ResultExt, maybe, merge_json_value_into}; fn typescript_server_binary_arguments(server_path: &Path) -> Vec { vec![server_path.into(), "--stdio".into()] @@ -29,19 +29,19 @@ impl VtslsLspAdapter { const TYPESCRIPT_PACKAGE_NAME: &'static str = "typescript"; const TYPESCRIPT_TSDK_PATH: &'static str = "node_modules/typescript/lib"; + const TYPESCRIPT_YARN_TSDK_PATH: &'static str = ".yarn/sdks/typescript/lib"; pub fn new(node: NodeRuntime, fs: Arc) -> Self { VtslsLspAdapter { node, fs } } async fn tsdk_path(&self, adapter: &Arc) -> Option<&'static str> { - let is_yarn = adapter - .read_text_file(RelPath::unix(".yarn/sdks/typescript/lib/typescript.js").unwrap()) - .await - .is_ok(); + let yarn_sdk = adapter + .worktree_root_path() + .join(Self::TYPESCRIPT_YARN_TSDK_PATH); - let tsdk_path = if is_yarn { - ".yarn/sdks/typescript/lib" + let tsdk_path = if self.fs.is_dir(&yarn_sdk).await { + Self::TYPESCRIPT_YARN_TSDK_PATH } else { Self::TYPESCRIPT_TSDK_PATH };