Fix tests ignoring overflowing cursors
This commit is contained in:
parent
535b76bb71
commit
78525cef45
2 changed files with 13 additions and 0 deletions
|
|
@ -63,6 +63,13 @@ impl ExampleDocument {
|
||||||
fn text_with_cursors_to_string(text: &TextWithCursors<'_>) -> String {
|
fn text_with_cursors_to_string(text: &TextWithCursors<'_>) -> String {
|
||||||
let mut result = text.text.clone().into_owned();
|
let mut result = text.text.clone().into_owned();
|
||||||
for (i, cursor) in text.cursors.iter().enumerate() {
|
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.insert(
|
||||||
result
|
result
|
||||||
.char_indices()
|
.char_indices()
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,9 @@ parent: long text with one big delete and many small
|
||||||
left: long small
|
left: long small
|
||||||
right: long with big and small
|
right: long with big and small
|
||||||
expected: long 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|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue