diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f23f796692..3467d55771 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2403,8 +2403,9 @@ impl Editor { let mut to_unfold = Vec::new(); let mut new_selections = Vec::new(); { + let selections = self.selections::(cx); let buffer = self.buffer.read(cx).read(cx); - for selection in self.selections::(cx) { + for selection in selections { for row in selection.start.row..selection.end.row { let cursor = Point::new(row, buffer.line_len(row)); new_selections.push(Selection { diff --git a/crates/language/src/multi_buffer/anchor.rs b/crates/language/src/multi_buffer/anchor.rs index 7bc8c85848..2b8b35ef41 100644 --- a/crates/language/src/multi_buffer/anchor.rs +++ b/crates/language/src/multi_buffer/anchor.rs @@ -31,6 +31,9 @@ impl Anchor { pub fn cmp<'a>(&self, other: &Anchor, snapshot: &MultiBufferSnapshot) -> Result { let excerpt_id_cmp = self.excerpt_id.cmp(&other.excerpt_id); if excerpt_id_cmp.is_eq() { + if self.excerpt_id == ExcerptId::max() { + return Ok(Ordering::Equal); + } self.text_anchor.cmp( &other.text_anchor, snapshot