Conversation
| function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, start: number): void { | ||
| const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); | ||
| const statement = cast(token.parent, isLabeledStatement).statement; | ||
| changes.deleteRange(sourceFile, { pos: token.getStart(sourceFile), end: statement.getStart(sourceFile) }); |
There was a problem hiding this comment.
this will remove comments on the statement before the label.. if you are deleting a range, why not just delete from token.pos to :.end?
There was a problem hiding this comment.
I wanted to remove the space between the : and the statement following it. token.getStart should not include any comments preceding token. (But token.pos would.)
There was a problem hiding this comment.
/*not deleted*/ label /*deleted*/ : /*deleted*/ call();?
amcasey
left a comment
There was a problem hiding this comment.
I have concerns about the trivia, but I understand you're tracking that as its own (increasingly expensive) work item. Otherwise, LGTM.
| function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, start: number): void { | ||
| const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false); | ||
| const statement = cast(token.parent, isLabeledStatement).statement; | ||
| changes.deleteRange(sourceFile, { pos: token.getStart(sourceFile), end: statement.getStart(sourceFile) }); |
There was a problem hiding this comment.
/*not deleted*/ label /*deleted*/ : /*deleted*/ call();?
|
|
||
| // @noUnusedLocals: true | ||
|
|
||
| ////label1: while (1) {} |
There was a problem hiding this comment.
What happens for outdented labels on preceding lines?
label:
code
Does formatting restore the indentation? Otherwise, it seems like you'd end up with code outdented.
Similar to #24028