on master help sign in
Don't try to compose zero-width deletes.
4a64855Blaž Hrastnik
helix-core/src/transaction.rs+5−2
@@ -439,7 +439,9 @@ impl Transaction {
439 }
439 }
440 acc.push(Operation::Insert(text));
440 acc.push(Operation::Insert(text));
441 }
441 }
442− None => acc.push(Operation::Delete(span)),
442+ None if span > 0 => acc.push(Operation::Delete(span)),
443+ // empty delete is useless
444+ None => (),
443 }
445 }
444 last = to;
446 last = to;
445 }
447 }
@@ -577,7 +579,8 @@ mod test {
577 let mut state = State::new("hello world!\ntest 123".into());
579 let mut state = State::new("hello world!\ntest 123".into());
578 let transaction = Transaction::change(
580 let transaction = Transaction::change(
579 &state,
581 &state,
582+ // (1, 1, None) is a useless 0-width delete
580− vec![(6, 11, Some("void".into())), (12, 17, None)].into_iter(),
583+ vec![(6, 11, Some("void".into())), (12, 17, None), (1, 1, None)].into_iter(),
581 );
584 );
582 transaction.apply(&mut state);
585 transaction.apply(&mut state);
583 assert_eq!(state.doc, Rope::from_str("hello void! 123"));
586 assert_eq!(state.doc, Rope::from_str("hello void! 123"));