Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

fix: Absolutize path to worktree root in `worktree.read_text_file` (#19064)

Tim Havlicek518f8cc5b73c
diff --git a/crates/project/src/lsp_store.rs b/crates/project/src/lsp_store.rs
index 7a7bd2863b9..01e40ec6a00 100644
--- a/crates/project/src/lsp_store.rs
+++ b/crates/project/src/lsp_store.rs
@@ -7663,10 +7663,16 @@ impl LspAdapterDelegate for LocalLspAdapterDelegate {
}
async fn read_text_file(&self, path: PathBuf) -> Result<String> {
- 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
}
}