From 60245060b992336474d1f74dbd9bc21fc99365e6 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 a3763810e1a262e43daa8c1810d96cc8b10a0ffa..50a461e617104cb66620bd70b739c57753997f13 100644 --- a/crates/project/src/lsp_store.rs +++ b/crates/project/src/lsp_store.rs @@ -7617,10 +7617,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 } }