aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_text_edit/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_text_edit/src/lib.rs')
-rw-r--r--crates/ra_text_edit/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs
index 8acf10448..fb693b3ae 100644
--- a/crates/ra_text_edit/src/lib.rs
+++ b/crates/ra_text_edit/src/lib.rs
@@ -1,5 +1,4 @@
1mod text_edit; 1mod text_edit;
2pub mod text_utils;
3pub mod test_utils; 2pub mod test_utils;
4 3
5pub use crate::text_edit::{TextEdit, TextEditBuilder}; 4pub use crate::text_edit::{TextEdit, TextEditBuilder};
@@ -29,4 +28,11 @@ impl AtomTextEdit {
29 pub fn insert(offset: TextUnit, text: String) -> AtomTextEdit { 28 pub fn insert(offset: TextUnit, text: String) -> AtomTextEdit {
30 AtomTextEdit::replace(TextRange::offset_len(offset, 0.into()), text) 29 AtomTextEdit::replace(TextRange::offset_len(offset, 0.into()), text)
31 } 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 }
32} 38}