@@ -109,9 +109,7 @@ impl ChangeSet {
109109 Ordering::Greater => {
110110 // figure out the byte index of the truncated string end
111111 let (pos, _) = s.char_indices().nth(len - j).unwrap();
112− // calculate the difference
113− let to_drop = s.len() - pos;
114− s.pop_back(u32::try_from(to_drop).unwrap());
112+ s.pop_front(s.len() as u32 - pos as u32);
115113 head_a = Some(Insert(s));
116114 head_b = changes_b.next();
117115 }
@@ -487,7 +485,7 @@ mod test {
487485 let a = ChangeSet {
488486 changes: vec![
489487 Retain(5),
490− Insert("!".into()),
488+ Insert(" test!".into()),
491489 Retain(1),
492490 Delete(2),
493491 Insert("abc".into()),
@@ -496,8 +494,8 @@ mod test {
496494 };
497495
498496 let b = ChangeSet {
499− changes: vec![Delete(5), Insert("world".into()), Retain(5)],
500− len: 9,
497+ changes: vec![Delete(10), Insert("world".into()), Retain(5)],
498+ len: 15,
501499 };
502500
503501 let mut text = Rope::from("hello xz");