on master help sign in
fix: insert() | delete() would calculate the new insert incorrectly

Refs #386

commitca98210d2016d96d1c441932d7a67bbc6e5eccb7 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 28 Jun 2021, 17:47 (5 years ago) parentd4e1ec3
1 file changed+2−1
helix-core/src/transaction.rs+2−1
helix-core/src/transaction.rs+2−1
@@ -193,9 +193,10 @@ impl ChangeSet {
193193 head_b = changes_b.next();
194194 }
195195 Ordering::Greater => {
196+ // TODO: cover this with a test
196197 // figure out the byte index of the truncated string end
197198 let (pos, _) = s.char_indices().nth(len - j).unwrap();
198− s.pop_front(s.len() as u32 - pos as u32);
199+ s.pop_front(pos as u32);
199200 head_a = Some(Insert(s));
200201 head_b = changes_b.next();
201202 }