summaryrefslogtreecommitdiff
path: root/helix-core/src/transaction.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-22 03:21:33 +0000
committerBlaž Hrastnik2021-03-22 03:22:33 +0000
commit798dbd27c50296d260fe13483e4a3aacd240c6ad (patch)
tree4497787e897b54107c3c28da690faac0fe514def /helix-core/src/transaction.rs
parent71999cce43b3750362cdea534c12cbf320d2677b (diff)
Selection: fail early if new() is called with no ranges.
Diffstat (limited to 'helix-core/src/transaction.rs')
-rw-r--r--helix-core/src/transaction.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index 1f9e63aa..f25ee208 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -464,11 +464,13 @@ impl Transaction {
I: IntoIterator<Item = Change> + ExactSizeIterator,
{
let len = doc.len_chars();
- let acc = Vec::with_capacity(2 * changes.len() + 1);
+ let acc = Vec::with_capacity(2 * changes.len() + 1); // rough estimate
let mut changeset = ChangeSet { changes: acc, len };
// TODO: verify ranges are ordered and not overlapping or change will panic.
+ // TODO: test for (pos, pos, None) to factor out as nothing
+
let mut last = 0;
for (from, to, tendril) in changes {
// Retain from last "to" to current "from"