on master help sign in
Don't try to compose zero-width deletes.
commit4a648555ed7a61de615baad551bab8f34a5bad74 authorBlaž Hrastnik <blaz@mxxn.io> dateThu 8 Oct 2020, 14:21 (6 years ago) parent490e23b
1 file changed+5−2
helix-core/src/transaction.rs+5−2
helix-core/src/transaction.rs+5−2
@@ -439,7 +439,9 @@ impl Transaction {
439439 }
440440 acc.push(Operation::Insert(text));
441441 }
442− None => acc.push(Operation::Delete(span)),
442+ None if span > 0 => acc.push(Operation::Delete(span)),
443+ // empty delete is useless
444+ None => (),
443445 }
444446 last = to;
445447 }
@@ -577,7 +579,8 @@ mod test {
577579 let mut state = State::new("hello world!\ntest 123".into());
578580 let transaction = Transaction::change(
579581 &state,
580− vec![(6, 11, Some("void".into())), (12, 17, None)].into_iter(),
582+ // (1, 1, None) is a useless 0-width delete
583+ vec![(6, 11, Some("void".into())), (12, 17, None), (1, 1, None)].into_iter(),
581584 );
582585 transaction.apply(&mut state);
583586 assert_eq!(state.doc, Rope::from_str("hello void! 123"));