aboutsummaryrefslogtreecommitdiff
path: root/crates/text_edit
diff options
context:
space:
mode:
Diffstat (limited to 'crates/text_edit')
-rw-r--r--crates/text_edit/src/lib.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/text_edit/src/lib.rs b/crates/text_edit/src/lib.rs
index e417e8ea6..eb3c8caa2 100644
--- a/crates/text_edit/src/lib.rs
+++ b/crates/text_edit/src/lib.rs
@@ -119,7 +119,7 @@ impl TextEdit {
119 return Err(other); 119 return Err(other);
120 } 120 }
121 self.indels.extend(other.indels); 121 self.indels.extend(other.indels);
122 assert!(check_disjoint(&mut self.indels)); 122 assert_disjoint(&mut self.indels);
123 Ok(()) 123 Ok(())
124 } 124 }
125 125
@@ -169,7 +169,7 @@ impl TextEditBuilder {
169 } 169 }
170 pub fn finish(self) -> TextEdit { 170 pub fn finish(self) -> TextEdit {
171 let mut indels = self.indels; 171 let mut indels = self.indels;
172 assert!(check_disjoint(&mut indels)); 172 assert_disjoint(&mut indels);
173 TextEdit { indels } 173 TextEdit { indels }
174 } 174 }
175 pub fn invalidates_offset(&self, offset: TextSize) -> bool { 175 pub fn invalidates_offset(&self, offset: TextSize) -> bool {
@@ -178,11 +178,14 @@ impl TextEditBuilder {
178 fn indel(&mut self, indel: Indel) { 178 fn indel(&mut self, indel: Indel) {
179 self.indels.push(indel); 179 self.indels.push(indel);
180 if self.indels.len() <= 16 { 180 if self.indels.len() <= 16 {
181 check_disjoint(&mut self.indels); 181 assert_disjoint(&mut self.indels);
182 } 182 }
183 } 183 }
184} 184}
185 185
186fn assert_disjoint(indels: &mut [impl std::borrow::Borrow<Indel>]) {
187 assert!(check_disjoint(indels));
188}
186fn check_disjoint(indels: &mut [impl std::borrow::Borrow<Indel>]) -> bool { 189fn check_disjoint(indels: &mut [impl std::borrow::Borrow<Indel>]) -> bool {
187 indels.sort_by_key(|indel| (indel.borrow().delete.start(), indel.borrow().delete.end())); 190 indels.sort_by_key(|indel| (indel.borrow().delete.start(), indel.borrow().delete.end()));
188 indels 191 indels