File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,20 @@ namespace ts.codefix {
150
150
}
151
151
152
152
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 ) ;
154
167
}
155
168
156
169
function findFirstNonSpaceCharPosStarting ( start : number ) {
You can’t perform that action at this time.
0 commit comments