@@ -163,7 +163,7 @@ impl ChangeSet {
163 head_a = a;
163 head_a = a;
164 head_b = changes_b.next();
164 head_b = changes_b.next();
166− (None, _) | (_, None) => return unreachable!(),
166+ (None, val) | (val, None) => return unreachable!("({:?})", val),
167 (Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) {
167 (Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) {
168 Ordering::Less => {
168 Ordering::Less => {
169 changes.retain(i);
169 changes.retain(i);
@@ -195,7 +195,7 @@ impl ChangeSet {
195 Ordering::Greater => {
195 Ordering::Greater => {
196 // TODO: cover this with a test
196 // TODO: cover this with a test
197 // figure out the byte index of the truncated string end
197 // figure out the byte index of the truncated string end
198− let (pos, _) = s.char_indices().nth(len - j).unwrap();
198+ let (pos, _) = s.char_indices().nth(j).unwrap();
199 s.pop_front(pos as u32);
199 s.pop_front(pos as u32);
200 head_a = Some(Insert(s));
200 head_a = Some(Insert(s));
201 head_b = changes_b.next();
201 head_b = changes_b.next();
@@ -599,7 +599,7 @@ mod test {
601 let b = ChangeSet {
601 let b = ChangeSet {
602− changes: vec![Delete(10), Insert("world".into()), Retain(5)],
602+ changes: vec![Delete(10), Insert("世orld".into()), Retain(5)],
604 len_after: 10,
604 len_after: 10,
@@ -610,7 +610,7 @@ mod test {
610 let composed = a.compose(b);
610 let composed = a.compose(b);
611 assert_eq!(composed.len, 8);
611 assert_eq!(composed.len, 8);
612 assert!(composed.apply(&mut text));
612 assert!(composed.apply(&mut text));
613− assert_eq!(text, "world! abc");
613+ assert_eq!(text, "世orld! abc");