From 2611b5449ffa50da71458698869840bcb6914a56 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 25 Feb 2022 15:36:43 +0100 Subject: [PATCH] Always `sync` before clearing or removing excerpts from `MultiBuffer` We don't have any test that proves this is needed but seems good nonetheless. --- crates/editor/src/multi_buffer.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index 57c7b380676068769bdaebbe0ecd1199f04eeb06..42f4d72f52c6e14335b9bf6e260055a9a6325373 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -772,6 +772,7 @@ impl MultiBuffer { } pub fn clear(&mut self, cx: &mut ModelContext) { + self.sync(cx); self.buffers.borrow_mut().clear(); let mut snapshot = self.snapshot.borrow_mut(); let prev_len = snapshot.len(); @@ -853,6 +854,7 @@ impl MultiBuffer { excerpt_ids: impl IntoIterator, cx: &mut ModelContext, ) { + self.sync(cx); let mut buffers = self.buffers.borrow_mut(); let mut snapshot = self.snapshot.borrow_mut(); let mut new_excerpts = SumTree::new();