@@ -164,11 +164,14 @@ export default class Chunk {
164164
165165 if ( trimmed . length ) {
166166 if ( trimmed !== this . content ) {
167- this . split ( this . start + trimmed . length ) . edit ( '' , undefined , true )
168167 if ( this . edited ) {
169- // save the change, if it has been edited
168+ // the content of an edited chunk no longer lines up with its range in the
169+ // original string, so there is no index to split at - trim it in place
170170 this . edit ( trimmed , this . storeName , true )
171171 }
172+ else {
173+ this . split ( this . start + trimmed . length ) . edit ( '' , undefined , true )
174+ }
172175 }
173176 return true
174177 }
@@ -190,12 +193,15 @@ export default class Chunk {
190193
191194 if ( trimmed . length ) {
192195 if ( trimmed !== this . content ) {
193- const newChunk = this . split ( this . end - trimmed . length )
194196 if ( this . edited ) {
195- // save the change, if it has been edited
196- newChunk . edit ( trimmed , this . storeName , true )
197+ // the content of an edited chunk no longer lines up with its range in the
198+ // original string, so there is no index to split at - trim it in place
199+ this . edit ( trimmed , this . storeName , true )
200+ }
201+ else {
202+ this . split ( this . end - trimmed . length )
203+ this . edit ( '' , undefined , true )
197204 }
198- this . edit ( '' , undefined , true )
199205 }
200206 return true
201207 }
0 commit comments