Fix tests ignoring overflowing cursors

This commit is contained in:
Andras Schmelczer 2025-04-13 22:21:19 +01:00
parent 535b76bb71
commit 78525cef45
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
2 changed files with 13 additions and 0 deletions

View file

@ -63,6 +63,13 @@ impl ExampleDocument {
fn text_with_cursors_to_string(text: &TextWithCursors<'_>) -> String {
let mut result = text.text.clone().into_owned();
for (i, cursor) in text.cursors.iter().enumerate() {
assert!(
cursor.char_index <= result.len(), // equals in case of insert at the end
"Cursor index out of bounds: {} > {}",
cursor.char_index,
result.len()
);
result.insert(
result
.char_indices()