From 3386e34f1a56b825c5cfa701d488c96d4c7804d4 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Tue, 25 Mar 2025 14:37:56 +0200 Subject: [PATCH] Don't assume that the excerpt can be found (cherry-pick #27395) (#27398) Cherry-picked Don't assume that the excerpt can be found (#27395) Release Notes: - Fix (rare) panic in the project diff view Co-authored-by: Conrad Irwin --- crates/multi_buffer/src/multi_buffer.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs index aad3c28effce0e9cd8b69dab14c6c1cf5c242d0c..18d1a0b7db4b592aef0fe93d6c2050c9eade5fe2 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());