@@ -159,13 +159,13 @@ impl<'a> IntoIterator for &'a TextEdit {
159
159
160
160
impl TextEditBuilder {
161
161
pub fn replace ( & mut self , range : TextRange , replace_with : String ) {
162
- self . indels . push ( Indel :: replace ( range, replace_with) )
162
+ self . indel ( Indel :: replace ( range, replace_with) )
163
163
}
164
164
pub fn delete ( & mut self , range : TextRange ) {
165
- self . indels . push ( Indel :: delete ( range) )
165
+ self . indel ( Indel :: delete ( range) )
166
166
}
167
167
pub fn insert ( & mut self , offset : TextSize , text : String ) {
168
- self . indels . push ( Indel :: insert ( offset, text) )
168
+ self . indel ( Indel :: insert ( offset, text) )
169
169
}
170
170
pub fn finish ( self ) -> TextEdit {
171
171
let mut indels = self . indels ;
@@ -175,6 +175,12 @@ impl TextEditBuilder {
175
175
pub fn invalidates_offset ( & self , offset : TextSize ) -> bool {
176
176
self . indels . iter ( ) . any ( |indel| indel. delete . contains_inclusive ( offset) )
177
177
}
178
+ fn indel ( & mut self , indel : Indel ) {
179
+ self . indels . push ( indel) ;
180
+ if self . indels . len ( ) <= 16 {
181
+ check_disjoint ( & mut self . indels ) ;
182
+ }
183
+ }
178
184
}
179
185
180
186
fn check_disjoint ( indels : & mut [ impl std:: borrow:: Borrow < Indel > ] ) -> bool {
0 commit comments