Skip to content

Commit

Permalink
delete import comments on organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Trinity committed May 15, 2020
1 parent 7fc456f commit 428f5a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/organizeImports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace ts.OrganizeImports {

// Delete any subsequent imports.
for (let i = 1; i < oldImportDecls.length; i++) {
changeTracker.delete(sourceFile, oldImportDecls[i]);
changeTracker.deleteNode(sourceFile, oldImportDecls[i]);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/services/textChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ namespace ts.textChanges {
this.deletedNodes.push({ sourceFile, node });
}

public deleteNode(sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }): void {
const startPosition = getAdjustedStartPosition(sourceFile, node, options);
const endPosition = getAdjustedEndPosition(sourceFile, node, options);
this.deleteRange(sourceFile, { pos: startPosition, end: endPosition });
}

public deleteModifier(sourceFile: SourceFile, modifier: Modifier): void {
this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) });
}
Expand Down

0 comments on commit 428f5a1

Please sign in to comment.