1
0
Fork 0
mirror of https://github.com/helix-editor/helix synced 2024-06-08 10:06:04 +02:00

Don't try to compose zero-width deletes.

This commit is contained in:
Blaž Hrastnik 2020-10-08 14:21:03 +09:00
parent 490e23b645
commit 4a648555ed

View File

@ -439,7 +439,9 @@ pub fn change<I>(state: &State, changes: I) -> Self
}
acc.push(Operation::Insert(text));
}
None => acc.push(Operation::Delete(span)),
None if span > 0 => acc.push(Operation::Delete(span)),
// empty delete is useless
None => (),
}
last = to;
}
@ -577,7 +579,8 @@ fn transaction_change() {
let mut state = State::new("hello world!\ntest 123".into());
let transaction = Transaction::change(
&state,
vec![(6, 11, Some("void".into())), (12, 17, None)].into_iter(),
// (1, 1, None) is a useless 0-width delete
vec![(6, 11, Some("void".into())), (12, 17, None), (1, 1, None)].into_iter(),
);
transaction.apply(&mut state);
assert_eq!(state.doc, Rope::from_str("hello void! 123"));