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:
Andrew Casey committed 2017-10-12 14:19:36 -07:00
1 parent 98f04e6cfd
commit 2ea4cfe23b
71 files changed
+74 -2

No files matched your search

+4 -1
View File
@@ -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[] = [];