From 25a5ad54ae536341e42c0e5065079f57451b5925 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 9 Dec 2024 21:43:25 +0200 Subject: [PATCH] Sync newly added diff hunks (#21759) Fixed project diff multi buffer not expanding its diff until edited Release Notes: - N/A --- crates/editor/src/git/project_diff.rs | 10 +++++----- crates/editor/src/hunk_diff.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/git/project_diff.rs b/crates/editor/src/git/project_diff.rs index 8fb600c52c1dfaf13209a8d63152027fbc2fc834..c1fbbee8b2b27ed48020b030f5f0799f3d436740 100644 --- a/crates/editor/src/git/project_diff.rs +++ b/crates/editor/src/git/project_diff.rs @@ -243,7 +243,7 @@ impl ProjectDiffEditor { .map_err(|_| anyhow!("Unexpected non-buffer")) }) .with_context(|| { - format!("loading {} for git diff", entry_path.path.display()) + format!("loading {:?} for git diff", entry_path.path) }) .log_err() else { @@ -313,11 +313,11 @@ impl ProjectDiffEditor { project_diff_editor .update(&mut cx, |project_diff_editor, cx| { project_diff_editor.update_excerpts(id, new_changes, new_entry_order, cx); - for change_set in change_sets { - project_diff_editor.editor.update(cx, |editor, cx| { + project_diff_editor.editor.update(cx, |editor, cx| { + for change_set in change_sets { editor.diff_map.add_change_set(change_set, cx) - }); - } + } + }); }) .ok(); }), diff --git a/crates/editor/src/hunk_diff.rs b/crates/editor/src/hunk_diff.rs index 3f798eaa588accde590bad1a4512a4472b54093b..2102c111f66e837a955c1df01b6b56d15be981fc 100644 --- a/crates/editor/src/hunk_diff.rs +++ b/crates/editor/src/hunk_diff.rs @@ -89,7 +89,6 @@ impl DiffMap { self.snapshot .0 .insert(buffer_id, change_set.read(cx).diff_to_buffer.clone()); - Editor::sync_expanded_diff_hunks(self, buffer_id, cx); self.diff_bases.insert( buffer_id, DiffBaseState { @@ -105,6 +104,7 @@ impl DiffMap { change_set, }, ); + Editor::sync_expanded_diff_hunks(self, buffer_id, cx); } pub fn hunks(&self, include_folded: bool) -> impl Iterator {