Properly invalidate when async git diff completes

Julia created

Change summary

crates/editor/src/items.rs    | 1 -
crates/language/src/buffer.rs | 5 +++--
2 files changed, 3 insertions(+), 3 deletions(-)

Detailed changes

crates/editor/src/items.rs 🔗

@@ -486,7 +486,6 @@ impl Item for Editor {
         self.buffer().update(cx, |multibuffer, cx| {
             multibuffer.update_git(cx);
         });
-        cx.notify();
         Task::ready(Ok(()))
     }
 

crates/language/src/buffer.rs 🔗

@@ -662,7 +662,6 @@ impl Buffer {
         if self.head_text.is_some() {
             let snapshot = self.snapshot();
             let head_text = self.head_text.clone();
-            self.diff_update_count += 1;
 
             let buffer_diff = cx
                 .background()
@@ -671,8 +670,10 @@ impl Buffer {
             cx.spawn_weak(|this, mut cx| async move {
                 let buffer_diff = buffer_diff.await;
                 if let Some(this) = this.upgrade(&cx) {
-                    this.update(&mut cx, |this, _| {
+                    this.update(&mut cx, |this, cx| {
                         this.git_diff = buffer_diff;
+                        this.diff_update_count += 1;
+                        cx.notify();
                     })
                 }
             })