aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-10-08 05:21:03 +0000
committerBlaž Hrastnik2020-10-13 14:13:56 +0000
commit4a648555ed7a61de615baad551bab8f34a5bad74 (patch)
treeeee19e60c87b6b7cfa9f01bfc7fc1801f2f1edd1 /helix-core/src
parent490e23b645311fef86d8e8045f97f514927d2867 (diff)
Don't try to compose zero-width deletes.
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/transaction.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index 86fc0bc8..a84313b2 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -439,7 +439,9 @@ impl Transaction {
}
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 @@ mod test {
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"));