multi_buffer: Fix up some anchor checks (#43454)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-11-25 13:41:19 +00:00
committed by GitHub
parent a359a5a1f2
commit f8965317c3
15 changed files with 154 additions and 58 deletions
@@ -415,6 +415,29 @@ impl SelectionsCollection {
!mutable_collection.disjoint.is_empty() || mutable_collection.pending.is_some(),
"There must be at least one selection"
);
if cfg!(debug_assertions) {
mutable_collection.disjoint.iter().for_each(|selection| {
assert!(
snapshot.can_resolve(&selection.start),
"disjoint selection start is not resolvable for the given snapshot:\n{selection:?}",
);
assert!(
snapshot.can_resolve(&selection.end),
"disjoint selection end is not resolvable for the given snapshot: {selection:?}",
);
});
if let Some(pending) = &mutable_collection.pending {
let selection = &pending.selection;
assert!(
snapshot.can_resolve(&selection.start),
"pending selection start is not resolvable for the given snapshot: {pending:?}",
);
assert!(
snapshot.can_resolve(&selection.end),
"pending selection end is not resolvable for the given snapshot: {pending:?}",
);
}
}
(mutable_collection.selections_changed, result)
}