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()

View file

@ -23,3 +23,9 @@ parent: long text with one big delete and many small
left: long small
right: long with big and small
expected: long small
---
parent: long text where the cursor has to be clamped after delete
left: long text where the cursor has to be clamped after delete|
right: long text where the cursor
expected: long text where the cursor|