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))
This commit is contained in:
Tim Havlicek 2024-10-11 12:26:37 +02:00 committed by GitHub
parent ccaf3268f8
commit 518f8cc5b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}
}