diff options
author | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-08 11:49:43 +0000 |
commit | 12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch) | |
tree | 71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/ra_text_edit | |
parent | 5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff) |
reformat the world
Diffstat (limited to 'crates/ra_text_edit')
-rw-r--r-- | crates/ra_text_edit/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_text_edit/src/test_utils.rs | 8 | ||||
-rw-r--r-- | crates/ra_text_edit/src/text_edit.rs | 4 |
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 | ||
16 | impl AtomTextEdit { | 16 | impl 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 | ||
10 | fn text_offsets(text: &str) -> Vec<TextUnit> { | 10 | fn 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 | ||
16 | pub fn arb_offset(text: &str) -> BoxedStrategy<TextUnit> { | 14 | pub 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 | ||