From e2056756ef97af2add0221ad8916315939d476db Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 18 Sep 2023 17:34:58 +0300 Subject: [PATCH] Calculate the diff --- crates/prettier/src/prettier.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/prettier/src/prettier.rs b/crates/prettier/src/prettier.rs index 180b9c3de5..f94801c01b 100644 --- a/crates/prettier/src/prettier.rs +++ b/crates/prettier/src/prettier.rs @@ -187,6 +187,7 @@ impl Prettier { buffer: &ModelHandle, cx: &AsyncAppContext, ) -> anyhow::Result { + // TODO kb prettier needs either a path or a `parser` (depends on a language) option to format let (buffer_text, buffer_language) = buffer.read_with(cx, |buffer, _| (buffer.text(), buffer.language().cloned())); let response = self @@ -198,8 +199,8 @@ impl Prettier { }) .await .context("prettier format request")?; - dbg!("Formatted text", response.text); - anyhow::bail!("TODO kb calculate the diff") + let diff_task = buffer.read_with(cx, |buffer, cx| buffer.diff(response.text, cx)); + Ok(diff_task.await) } pub async fn clear_cache(&self) -> anyhow::Result<()> {