File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -150,7 +150,20 @@ namespace ts.codefix {
150150 }
151151
152152 function createCodeFixToRemoveNode ( node : Node ) {
153- return createCodeFix ( "" , node . getStart ( ) , node . getWidth ( ) ) ;
153+ let end = node . getEnd ( ) ;
154+ const endCharCode = sourceFile . text . charCodeAt ( end ) ;
155+ const afterEndCharCode = sourceFile . text . charCodeAt ( end + 1 ) ;
156+ if ( isLineBreak ( endCharCode ) ) {
157+ end += 1 ;
158+ }
159+ // in the case of CR LF, you could have two consecutive new line characters for one new line.
160+ // this needs to be differenciated from two LF LF chars that actually mean two new lines.
161+ if ( isLineBreak ( afterEndCharCode ) && endCharCode !== afterEndCharCode ) {
162+ end += 1 ;
163+ }
164+
165+ const start = node . getStart ( ) ;
166+ return createCodeFix ( "" , start , end - start ) ;
154167 }
155168
156169 function findFirstNonSpaceCharPosStarting ( start : number ) {
You can’t perform that action at this time.
0 commit comments