aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_text_edit
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_text_edit')
-rw-r--r--crates/ra_text_edit/src/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs
index 22f3fdc0c..fb693b3ae 100644
--- a/crates/ra_text_edit/src/lib.rs
+++ b/crates/ra_text_edit/src/lib.rs
@@ -28,4 +28,11 @@ impl AtomTextEdit {
28 pub fn insert(offset: TextUnit, text: String) -> AtomTextEdit { 28 pub fn insert(offset: TextUnit, text: String) -> AtomTextEdit {
29 AtomTextEdit::replace(TextRange::offset_len(offset, 0.into()), text) 29 AtomTextEdit::replace(TextRange::offset_len(offset, 0.into()), text)
30 } 30 }
31
32 pub fn apply(&self, mut text: String) -> String {
33 let start = u32::from(self.delete.start()) as usize;
34 let end = u32::from(self.delete.end()) as usize;
35 text.replace_range(start..end, &self.insert);
36 text
37 }
31} 38}