diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index c91547c23049adc4faba7349b8df8638a9fdbc59..998deb197fa0ac622da50f3e9969f4774921f63e 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -12757,7 +12757,10 @@ impl LspAdapterDelegate for LocalLspAdapterDelegate { #[cfg(not(target_os = "windows"))] async fn which(&self, command: &OsStr) -> Option { - let worktree_abs_path = self.worktree.abs_path(); + let mut worktree_abs_path = self.worktree_root_path().to_path_buf(); + if self.fs.is_file(&worktree_abs_path).await { + worktree_abs_path.pop(); + } let shell_path = self.shell_env().await.get("PATH").cloned(); which::which_in(command, shell_path.as_ref(), worktree_abs_path).ok() } @@ -12771,7 +12774,10 @@ impl LspAdapterDelegate for LocalLspAdapterDelegate { } async fn try_exec(&self, command: LanguageServerBinary) -> Result<()> { - let working_dir = self.worktree_root_path(); + let mut working_dir = self.worktree_root_path().to_path_buf(); + if self.fs.is_file(&working_dir).await { + working_dir.pop(); + } let output = util::command::new_smol_command(&command.path) .args(command.arguments) .envs(command.env.clone().unwrap_or_default())