File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -813,20 +813,24 @@ const textLinesMutator = (lines) => {
813
813
let removed = '' ;
814
814
if ( isCurLineInSplice ( ) ) {
815
815
if ( curCol === 0 ) {
816
+ // First line to be removed is in splice.
816
817
removed = curSplice [ curSplice . length - 1 ] ;
817
818
curSplice . length -- ;
819
+ // Next lines to be removed are not in splice.
818
820
removed += nextKLinesText ( L - 1 ) ;
819
821
curSplice [ 1 ] += L - 1 ;
820
822
} else {
821
823
removed = nextKLinesText ( L - 1 ) ;
822
824
curSplice [ 1 ] += L - 1 ;
823
825
const sline = curSplice . length - 1 ;
824
826
removed = curSplice [ sline ] . substring ( curCol ) + removed ;
825
- curSplice [ sline ] = curSplice [ sline ] . substring ( 0 , curCol ) +
826
- linesGet ( curSplice [ 0 ] + curSplice [ 1 ] ) ;
827
- curSplice [ 1 ] += 1 ;
827
+ // Is there a line left?
828
+ const remaining = linesGet ( curSplice [ 0 ] + curSplice [ 1 ] ) || '' ;
829
+ curSplice [ sline ] = curSplice [ sline ] . substring ( 0 , curCol ) + remaining ;
830
+ curSplice [ 1 ] += remaining ? 1 : 0 ;
828
831
}
829
832
} else {
833
+ // Nothing that is removed is in splice. Implies curCol === 0.
830
834
removed = nextKLinesText ( L ) ;
831
835
curSplice [ 1 ] += L ;
832
836
}
You can’t perform that action at this time.
0 commit comments