mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Don't insert a blank line after extracted locals at the start of the file
This commit is contained in:
@@ -279,7 +279,7 @@ namespace ts.codefix {
|
||||
changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl);
|
||||
}
|
||||
else {
|
||||
changeTracker.insertNodeAtTopOfFile(sourceFile, importDecl);
|
||||
changeTracker.insertNodeAtTopOfFile(sourceFile, importDecl, /*blankLineBetween*/ true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1077,7 +1077,7 @@ namespace ts.refactor.extractSymbol {
|
||||
// Declare
|
||||
const nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope);
|
||||
if (nodeToInsertBefore.pos === 0) {
|
||||
changeTracker.insertNodeAtTopOfFile(context.file, newVariableStatement);
|
||||
changeTracker.insertNodeAtTopOfFile(context.file, newVariableStatement, /*blankLineBetween*/ false);
|
||||
}
|
||||
else {
|
||||
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false);
|
||||
|
||||
@@ -332,11 +332,11 @@ namespace ts.textChanges {
|
||||
return this;
|
||||
}
|
||||
|
||||
public insertNodeAtTopOfFile(sourceFile: SourceFile, newNode: Statement): void {
|
||||
public insertNodeAtTopOfFile(sourceFile: SourceFile, newNode: Statement, blankLineBetween: boolean): void {
|
||||
const pos = getInsertionPositionAtSourceFileTop(sourceFile);
|
||||
this.insertNodeAt(sourceFile, pos, newNode, {
|
||||
prefix: pos === 0 ? undefined : this.newLineCharacter,
|
||||
suffix: isLineBreak(sourceFile.text.charCodeAt(pos)) ? this.newLineCharacter : this.newLineCharacter + this.newLineCharacter,
|
||||
suffix: (isLineBreak(sourceFile.text.charCodeAt(pos)) ? "" : this.newLineCharacter) + (blankLineBetween ? this.newLineCharacter : ""),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user