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/lib.rs5
-rw-r--r--crates/ra_text_edit/src/test_utils.rs8
-rw-r--r--crates/ra_text_edit/src/text_edit.rs4
3 files changed, 4 insertions, 13 deletions
diff --git a/crates/ra_text_edit/src/lib.rs b/crates/ra_text_edit/src/lib.rs
index fb693b3ae..df673ba18 100644
--- a/crates/ra_text_edit/src/lib.rs
+++ b/crates/ra_text_edit/src/lib.rs
@@ -15,10 +15,7 @@ pub struct AtomTextEdit {
15 15
16impl AtomTextEdit { 16impl AtomTextEdit {
17 pub fn replace(range: TextRange, replace_with: String) -> AtomTextEdit { 17 pub fn replace(range: TextRange, replace_with: String) -> AtomTextEdit {
18 AtomTextEdit { 18 AtomTextEdit { delete: range, insert: replace_with }
19 delete: range,
20 insert: replace_with,
21 }
22 } 19 }
23 20
24 pub fn delete(range: TextRange) -> AtomTextEdit { 21 pub fn delete(range: TextRange) -> AtomTextEdit {
diff --git a/crates/ra_text_edit/src/test_utils.rs b/crates/ra_text_edit/src/test_utils.rs
index 745f21c93..9e21b24f6 100644
--- a/crates/ra_text_edit/src/test_utils.rs
+++ b/crates/ra_text_edit/src/test_utils.rs
@@ -8,9 +8,7 @@ pub fn arb_text() -> proptest::string::RegexGeneratorStrategy<String> {
8} 8}
9 9
10fn text_offsets(text: &str) -> Vec<TextUnit> { 10fn text_offsets(text: &str) -> Vec<TextUnit> {
11 text.char_indices() 11 text.char_indices().map(|(i, _)| TextUnit::from_usize(i)).collect()
12 .map(|(i, _)| TextUnit::from_usize(i))
13 .collect()
14} 12}
15 13
16pub fn arb_offset(text: &str) -> BoxedStrategy<TextUnit> { 14pub fn arb_offset(text: &str) -> BoxedStrategy<TextUnit> {
@@ -56,9 +54,7 @@ pub fn arb_text_edit(text: &str) -> BoxedStrategy<TextEdit> {
56 ) 54 )
57 .boxed() 55 .boxed()
58 } 56 }
59 &[x] => arb_text() 57 &[x] => arb_text().prop_map(move |text| AtomTextEdit::insert(x, text)).boxed(),
60 .prop_map(move |text| AtomTextEdit::insert(x, text))
61 .boxed(),
62 _ => unreachable!(), 58 _ => unreachable!(),
63 }) 59 })
64 .collect(); 60 .collect();
diff --git a/crates/ra_text_edit/src/text_edit.rs b/crates/ra_text_edit/src/text_edit.rs
index 363b3d8c0..8522f99bd 100644
--- a/crates/ra_text_edit/src/text_edit.rs
+++ b/crates/ra_text_edit/src/text_edit.rs
@@ -25,9 +25,7 @@ impl TextEditBuilder {
25 TextEdit::from_atoms(self.atoms) 25 TextEdit::from_atoms(self.atoms)
26 } 26 }
27 pub fn invalidates_offset(&self, offset: TextUnit) -> bool { 27 pub fn invalidates_offset(&self, offset: TextUnit) -> bool {
28 self.atoms 28 self.atoms.iter().any(|atom| atom.delete.contains_inclusive(offset))
29 .iter()
30 .any(|atom| atom.delete.contains_inclusive(offset))
31 } 29 }
32} 30}
33 31