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 @@ -813,20 +813,24 @@ const textLinesMutator = (lines) => {
813813 let removed = '' ;
814814 if ( isCurLineInSplice ( ) ) {
815815 if ( curCol === 0 ) {
816+ // First line to be removed is in splice.
816817 removed = curSplice [ curSplice . length - 1 ] ;
817818 curSplice . length -- ;
819+ // Next lines to be removed are not in splice.
818820 removed += nextKLinesText ( L - 1 ) ;
819821 curSplice [ 1 ] += L - 1 ;
820822 } else {
821823 removed = nextKLinesText ( L - 1 ) ;
822824 curSplice [ 1 ] += L - 1 ;
823825 const sline = curSplice . length - 1 ;
824826 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 ;
828831 }
829832 } else {
833+ // Nothing that is removed is in splice. Implies curCol === 0.
830834 removed = nextKLinesText ( L ) ;
831835 curSplice [ 1 ] += L ;
832836 }
You can’t perform that action at this time.
0 commit comments