diff options
Diffstat (limited to 'crates/ra_editor/src/edit.rs')
-rw-r--r-- | crates/ra_editor/src/edit.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/crates/ra_editor/src/edit.rs b/crates/ra_editor/src/edit.rs index 46e687319..c3149ec54 100644 --- a/crates/ra_editor/src/edit.rs +++ b/crates/ra_editor/src/edit.rs | |||
@@ -1,8 +1,5 @@ | |||
1 | use crate::{TextRange, TextUnit}; | 1 | use crate::{TextRange, TextUnit}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{text_utils::contains_offset_nonstrict, AtomEdit}; |
3 | AtomEdit, | ||
4 | text_utils::contains_offset_nonstrict, | ||
5 | }; | ||
6 | 3 | ||
7 | #[derive(Debug, Clone)] | 4 | #[derive(Debug, Clone)] |
8 | pub struct Edit { | 5 | pub struct Edit { |
@@ -11,7 +8,7 @@ pub struct Edit { | |||
11 | 8 | ||
12 | #[derive(Debug)] | 9 | #[derive(Debug)] |
13 | pub struct EditBuilder { | 10 | pub struct EditBuilder { |
14 | atoms: Vec<AtomEdit> | 11 | atoms: Vec<AtomEdit>, |
15 | } | 12 | } |
16 | 13 | ||
17 | impl EditBuilder { | 14 | impl EditBuilder { |
@@ -36,7 +33,9 @@ impl EditBuilder { | |||
36 | Edit { atoms } | 33 | Edit { atoms } |
37 | } | 34 | } |
38 | pub fn invalidates_offset(&self, offset: TextUnit) -> bool { | 35 | pub fn invalidates_offset(&self, offset: TextUnit) -> bool { |
39 | self.atoms.iter().any(|atom| contains_offset_nonstrict(atom.delete, offset)) | 36 | self.atoms |
37 | .iter() | ||
38 | .any(|atom| contains_offset_nonstrict(atom.delete, offset)) | ||
40 | } | 39 | } |
41 | } | 40 | } |
42 | 41 | ||
@@ -74,7 +73,7 @@ impl Edit { | |||
74 | break; | 73 | break; |
75 | } | 74 | } |
76 | if offset < atom.delete.end() { | 75 | if offset < atom.delete.end() { |
77 | return None | 76 | return None; |
78 | } | 77 | } |
79 | res += TextUnit::of_str(&atom.insert); | 78 | res += TextUnit::of_str(&atom.insert); |
80 | res -= atom.delete.len(); | 79 | res -= atom.delete.len(); |