mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-19 13:37:06 +04:00
fix ca98210d20
This commit is contained in:
parent
6214d707f3
commit
51162ae6b2
@ -163,7 +163,7 @@ pub fn compose(self, other: Self) -> Self {
|
|||||||
head_a = a;
|
head_a = a;
|
||||||
head_b = changes_b.next();
|
head_b = changes_b.next();
|
||||||
}
|
}
|
||||||
(None, _) | (_, None) => return unreachable!(),
|
(None, val) | (val, None) => return unreachable!("({:?})", val),
|
||||||
(Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) {
|
(Some(Retain(i)), Some(Retain(j))) => match i.cmp(&j) {
|
||||||
Ordering::Less => {
|
Ordering::Less => {
|
||||||
changes.retain(i);
|
changes.retain(i);
|
||||||
@ -195,7 +195,7 @@ pub fn compose(self, other: Self) -> Self {
|
|||||||
Ordering::Greater => {
|
Ordering::Greater => {
|
||||||
// TODO: cover this with a test
|
// TODO: cover this with a test
|
||||||
// figure out the byte index of the truncated string end
|
// figure out the byte index of the truncated string end
|
||||||
let (pos, _) = s.char_indices().nth(len - j).unwrap();
|
let (pos, _) = s.char_indices().nth(j).unwrap();
|
||||||
s.pop_front(pos as u32);
|
s.pop_front(pos as u32);
|
||||||
head_a = Some(Insert(s));
|
head_a = Some(Insert(s));
|
||||||
head_b = changes_b.next();
|
head_b = changes_b.next();
|
||||||
@ -599,7 +599,7 @@ fn composition() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let b = ChangeSet {
|
let b = ChangeSet {
|
||||||
changes: vec![Delete(10), Insert("world".into()), Retain(5)],
|
changes: vec![Delete(10), Insert("世orld".into()), Retain(5)],
|
||||||
len: 15,
|
len: 15,
|
||||||
len_after: 10,
|
len_after: 10,
|
||||||
};
|
};
|
||||||
@ -610,7 +610,7 @@ fn composition() {
|
|||||||
let composed = a.compose(b);
|
let composed = a.compose(b);
|
||||||
assert_eq!(composed.len, 8);
|
assert_eq!(composed.len, 8);
|
||||||
assert!(composed.apply(&mut text));
|
assert!(composed.apply(&mut text));
|
||||||
assert_eq!(text, "world! abc");
|
assert_eq!(text, "世orld! abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user