Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Don't assume that the excerpt can be found (#27395)

Conrad Irwin46d67a33c79b
diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs
index aad3c28effc..18d1a0b7db4 100644
--- a/crates/multi_buffer/src/multi_buffer.rs
+++ b/crates/multi_buffer/src/multi_buffer.rs
@@ -1645,7 +1645,11 @@ impl MultiBuffer {
};
let locator = snapshot.excerpt_locator_for_id(*existing);
excerpts_cursor.seek_forward(&Some(locator), Bias::Left, &());
- let existing_excerpt = excerpts_cursor.item().unwrap();
+ let Some(existing_excerpt) = excerpts_cursor.item() else {
+ to_remove.push(existing_iter.next().unwrap());
+ to_insert.push(new_iter.next().unwrap());
+ continue;
+ };
if existing_excerpt.buffer_id != buffer_snapshot.remote_id() {
to_remove.push(existing_iter.next().unwrap());
to_insert.push(new_iter.next().unwrap());