Fix early return when reaching end excerpt in `lift_buffer_metadata` (#26253)

Max Brunsfeld created

Release Notes:

- Fixed a bug causing slowness when viewing multi buffers with lots of
excerpts

Change summary

crates/multi_buffer/src/multi_buffer.rs | 5 +++++
1 file changed, 5 insertions(+)

Detailed changes

crates/multi_buffer/src/multi_buffer.rs 🔗

@@ -3830,6 +3830,11 @@ impl MultiBufferSnapshot {
             // When there are no more metadata items for this excerpt, move to the next excerpt.
             else {
                 current_excerpt_metadata.take();
+                if let Some((end_excerpt_id, _)) = range_end {
+                    if excerpt.id == end_excerpt_id {
+                        return None;
+                    }
+                }
                 cursor.next_excerpt();
             }
         })