Skip to content

Commit b952483

Browse files
authored
Fix branch diff hunk expansion (#41873)
Closes #ISSUE Release Notes: - (preview only) Fixes a bug where hunks were not expanded when viewing branch diff
1 parent e5660d2 commit b952483

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

crates/git_ui/src/project_diff.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,6 @@ impl ProjectDiff {
470470
window: &mut Window,
471471
cx: &mut Context<Self>,
472472
) {
473-
if self.branch_diff.read(cx).diff_base().is_merge_base() {
474-
self.multibuffer.update(cx, |multibuffer, cx| {
475-
multibuffer.add_diff(diff.clone(), cx);
476-
});
477-
}
478473
let subscription = cx.subscribe_in(&diff, window, move |this, _, _, window, cx| {
479474
this._task = window.spawn(cx, {
480475
let this = cx.weak_entity();
@@ -491,8 +486,8 @@ impl ProjectDiff {
491486
.expect("project diff editor should have a conflict addon");
492487

493488
let snapshot = buffer.read(cx).snapshot();
494-
let diff = diff.read(cx);
495-
let diff_hunk_ranges = diff
489+
let diff_read = diff.read(cx);
490+
let diff_hunk_ranges = diff_read
496491
.hunks_intersecting_range(Anchor::MIN..Anchor::MAX, &snapshot, cx)
497492
.map(|diff_hunk| diff_hunk.buffer_range);
498493
let conflicts = conflict_addon
@@ -515,6 +510,9 @@ impl ProjectDiff {
515510
multibuffer_context_lines(cx),
516511
cx,
517512
);
513+
if self.branch_diff.read(cx).diff_base().is_merge_base() {
514+
multibuffer.add_diff(diff.clone(), cx);
515+
}
518516
(was_empty, is_newly_added)
519517
});
520518

0 commit comments

Comments
 (0)