File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -904,20 +904,24 @@ class TextLinesMutator {
904904 let removed = '' ;
905905 if ( this . _isCurLineInSplice ( ) ) {
906906 if ( this . _curCol === 0 ) {
907+ // First line to be removed is in splice.
907908 removed = this . _curSplice [ this . _curSplice . length - 1 ] ;
908909 this . _curSplice . length -- ;
910+ // Next lines to be removed are not in splice.
909911 removed += nextKLinesText ( L - 1 ) ;
910912 this . _curSplice [ 1 ] += L - 1 ;
911913 } else {
912914 removed = nextKLinesText ( L - 1 ) ;
913915 this . _curSplice [ 1 ] += L - 1 ;
914916 const sline = this . _curSplice . length - 1 ;
915917 removed = this . _curSplice [ sline ] . substring ( this . _curCol ) + removed ;
916- this . _curSplice [ sline ] = this . _curSplice [ sline ] . substring ( 0 , this . _curCol ) +
917- this . _linesGet ( this . _curSplice [ 0 ] + this . _curSplice [ 1 ] ) ;
918- this . _curSplice [ 1 ] += 1 ;
918+ // Is there a line left?
919+ const remaining = this . _linesGet ( this . _curSplice [ 0 ] + this . _curSplice [ 1 ] ) || '' ;
920+ this . _curSplice [ sline ] = this . _curSplice [ sline ] . substring ( 0 , this . _curCol ) + remaining ;
921+ this . _curSplice [ 1 ] += remaining ? 1 : 0 ;
919922 }
920923 } else {
924+ // Nothing that is removed is in splice. Implies curCol === 0.
921925 removed = nextKLinesText ( L ) ;
922926 this . _curSplice [ 1 ] += L ;
923927 }
You can’t perform that action at this time.
0 commit comments