diff --git a/backend/reconcile/tests/example_document.rs b/backend/reconcile/tests/example_document.rs index 66a56f6..10790c8 100644 --- a/backend/reconcile/tests/example_document.rs +++ b/backend/reconcile/tests/example_document.rs @@ -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() diff --git a/backend/reconcile/tests/examples/deletes.yml b/backend/reconcile/tests/examples/deletes.yml index 59eb933..c4c145b 100644 --- a/backend/reconcile/tests/examples/deletes.yml +++ b/backend/reconcile/tests/examples/deletes.yml @@ -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|