aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/edit.rs
diff options
context:
space:
mode:
authorJeremy A. Kolb <[email protected]>2018-10-15 22:44:23 +0100
committerJeremy A. Kolb <[email protected]>2018-10-16 14:41:10 +0100
commit61f3a438d3a729a6be941bca1ff4c6a97a33f221 (patch)
tree6551967cc8c6e921b66071453ad7888a9121d326 /crates/ra_editor/src/edit.rs
parent39cb6c6d3f78b193f5873c3492e530bbd24d5dd2 (diff)
Cargo Format
Run `cargo fmt` and ignore generated files
Diffstat (limited to 'crates/ra_editor/src/edit.rs')
-rw-r--r--crates/ra_editor/src/edit.rs13
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 @@
1use crate::{TextRange, TextUnit}; 1use crate::{TextRange, TextUnit};
2use ra_syntax::{ 2use 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)]
8pub struct Edit { 5pub struct Edit {
@@ -11,7 +8,7 @@ pub struct Edit {
11 8
12#[derive(Debug)] 9#[derive(Debug)]
13pub struct EditBuilder { 10pub struct EditBuilder {
14 atoms: Vec<AtomEdit> 11 atoms: Vec<AtomEdit>,
15} 12}
16 13
17impl EditBuilder { 14impl 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();