diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1a1bf7cc66..3ca5798af4 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -4992,6 +4992,11 @@ impl Editor { pending_selection: Option, cx: &mut ViewContext, ) { + assert!( + !selections.is_empty() || pending_selection.is_some(), + "must have at least one selection" + ); + let old_cursor_position = self.newest_anchor_selection().head(); self.selections = selections; diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index fa35ad206b..c267ea775f 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -3357,7 +3357,7 @@ mod tests { } 40..=44 if !anchors.is_empty() => { let multibuffer = multibuffer.read(cx).read(cx); - + let prev_len = anchors.len(); anchors = multibuffer .refresh_anchors(&anchors) .into_iter() @@ -3366,6 +3366,7 @@ mod tests { // Ensure the newly-refreshed anchors point to a valid excerpt and don't // overshoot its boundaries. + assert_eq!(anchors.len(), prev_len); let mut cursor = multibuffer.excerpts.cursor::>(); for anchor in &anchors { if anchor.excerpt_id == ExcerptId::min()