Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Return last excerpt in MultiBuffer::excerpt_containing if overshooting
Antonio Scandurrab3c7526fb560
diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rsindex da3c6bc4bd4..e1e82859317 100644--- a/crates/editor/src/multi_buffer.rs+++ b/crates/editor/src/multi_buffer.rs@@ -1082,18 +1082,21 @@ impl MultiBuffer {let mut cursor = snapshot.excerpts.cursor::<usize>();cursor.seek(&position, Bias::Right, &());- cursor.item().map(|excerpt| {- (- excerpt.id.clone(),- self.buffers- .borrow()- .get(&excerpt.buffer_id)- .unwrap()- .buffer- .clone(),- excerpt.range.context.clone(),- )- })+ cursor+ .item()+ .or_else(|| snapshot.excerpts.last())+ .map(|excerpt| {+ (+ excerpt.id.clone(),+ self.buffers+ .borrow()+ .get(&excerpt.buffer_id)+ .unwrap()+ .buffer+ .clone(),+ excerpt.range.context.clone(),+ )+ })}// If point is at the end of the buffer, the last excerpt is returned