From 86e25104143d644fe0f7aff36f5368f3d9fc07c9 Mon Sep 17 00:00:00 2001 From: Tim Havlicek Date: Fri, 11 Oct 2024 12:26:37 +0200 Subject: [PATCH] fix: Absolutize path to worktree root in `worktree.read_text_file` (#19064) Closes #19050 Release Notes: - Fixed `worktree.read_text_file` plugin API working incorrectly ([#19050](https://github.com/zed-industries/zed/issues/19050)) --- crates/project/src/lsp_store.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs index b33416228e0d81fedb5174e100b9aaae187b300a..768622ddd5f9bbaa1220b56a6df8226e8d97b673 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -7656,10 +7656,16 @@ impl LspAdapterDelegate for LocalLspAdapterDelegate { } async fn read_text_file(&self, path: PathBuf) -> Result { - if self.worktree.entry_for_path(&path).is_none() { - return Err(anyhow!("no such path {path:?}")); - }; - self.fs.load(&path).await + let entry = self + .worktree + .entry_for_path(&path) + .with_context(|| format!("no worktree entry for path {path:?}"))?; + let abs_path = self + .worktree + .absolutize(&entry.path) + .with_context(|| format!("cannot absolutize path {path:?}"))?; + + self.fs.load(&abs_path).await } }