aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_text_edit/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_text_edit/src')
-rw-r--r--crates/ra_text_edit/src/text_edit.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_text_edit/src/text_edit.rs b/crates/ra_text_edit/src/text_edit.rs
index 3291ada42..5c37a08a8 100644
--- a/crates/ra_text_edit/src/text_edit.rs
+++ b/crates/ra_text_edit/src/text_edit.rs
@@ -63,12 +63,12 @@ impl TextEdit {
63 } 63 }
64 64
65 pub fn apply(&self, text: &str) -> String { 65 pub fn apply(&self, text: &str) -> String {
66 let mut total_len = text.len(); 66 let mut total_len = TextUnit::of_str(text);
67 for atom in self.atoms.iter() { 67 for atom in self.atoms.iter() {
68 total_len += atom.insert.len(); 68 total_len += TextUnit::of_str(&atom.insert);
69 total_len -= (atom.delete.end() - atom.delete.start()).to_usize(); 69 total_len -= atom.delete.end() - atom.delete.start();
70 } 70 }
71 let mut buf = String::with_capacity(total_len); 71 let mut buf = String::with_capacity(total_len.to_usize());
72 let mut prev = 0; 72 let mut prev = 0;
73 for atom in self.atoms.iter() { 73 for atom in self.atoms.iter() {
74 let start = atom.delete.start().to_usize(); 74 let start = atom.delete.start().to_usize();
@@ -80,7 +80,7 @@ impl TextEdit {
80 prev = end; 80 prev = end;
81 } 81 }
82 buf.push_str(&text[prev..text.len()]); 82 buf.push_str(&text[prev..text.len()]);
83 assert_eq!(buf.len(), total_len); 83 assert_eq!(TextUnit::of_str(&buf), total_len);
84 buf 84 buf
85 } 85 }
86 86