mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
Insert a line break before a function at EOF if needed
This is a pre-existing issue that became more obvious after refining trivia handling.
This commit is contained in:
@@ -4526,7 +4526,7 @@ namespace ts.projectSystem {
|
||||
{
|
||||
start: { line: 3, offset: 2 },
|
||||
end: { line: 3, offset: 2 },
|
||||
newText: "\nfunction newFunction() {\n 1;\n}\n",
|
||||
newText: "\n\nfunction newFunction() {\n 1;\n}\n",
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -785,7 +785,10 @@ namespace ts.refactor.extractSymbol {
|
||||
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter });
|
||||
}
|
||||
else {
|
||||
changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter });
|
||||
changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, {
|
||||
prefix: isLineBreak(file.text.charCodeAt(scope.getLastToken().pos)) ? context.newLineCharacter : context.newLineCharacter + context.newLineCharacter,
|
||||
suffix: context.newLineCharacter
|
||||
});
|
||||
}
|
||||
|
||||
const newNodes: Node[] = [];
|
||||
|
||||
Reference in New Issue
Block a user