diff options
author | Blaž Hrastnik | 2020-10-04 08:16:37 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2020-10-04 08:37:46 +0000 |
commit | 883b77bd246433ab221f16ee7be53ced9beb7c29 (patch) | |
tree | c721ad378a49fc64faf1ee2aa6d1a4b4b83cf325 /helix-core/src | |
parent | 197651eb309e88ba120dcb7a769acac6091483b1 (diff) |
Fix transaction.invert()/.apply() using byte counts instead of char counts.
Diffstat (limited to 'helix-core/src')
-rw-r--r-- | helix-core/src/transaction.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs index 7a00a4f0..14cb1c41 100644 --- a/helix-core/src/transaction.rs +++ b/helix-core/src/transaction.rs @@ -211,8 +211,9 @@ impl ChangeSet { pos += n; } Insert(s) => { - changes.push(Delete(s.len())); - len += s.len(); + let chars = s.chars().count(); + changes.push(Delete(chars)); + len += chars; } } } @@ -240,7 +241,7 @@ impl ChangeSet { } Insert(s) => { text.insert(pos, s); - pos += s.len(); + pos += s.chars().count(); } } } @@ -497,7 +498,7 @@ mod test { len: 12, }; - let doc = Rope::from("123 hello xz"); + let doc = Rope::from("世界3 hello xz"); let revert = changes.invert(&doc); let mut doc2 = doc.clone(); |