aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-06-28 08:47:23 +0000
committerBlaž Hrastnik2021-06-28 08:49:34 +0000
commitca98210d2016d96d1c441932d7a67bbc6e5eccb7 (patch)
tree536590dd7e634822741723e6ef3fe6f0bd7e9a52
parentd4e1ec339e022ffd5073873ac0bc64e3c095d064 (diff)
fix: insert() | delete() would calculate the new insert incorrectly
Refs #386
-rw-r--r--helix-core/src/transaction.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index 49ac396d..d55e2e9c 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -193,9 +193,10 @@ impl ChangeSet {
head_b = changes_b.next();
}
Ordering::Greater => {
+ // TODO: cover this with a test
// figure out the byte index of the truncated string end
let (pos, _) = s.char_indices().nth(len - j).unwrap();
- s.pop_front(s.len() as u32 - pos as u32);
+ s.pop_front(pos as u32);
head_a = Some(Insert(s));
head_b = changes_b.next();
}