mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
1 parent
50a0174582
commit
c60ff902f1
2 files changed
+64
-2
No files matched your search
@@ -1005,9 +1005,26 @@ namespace ts.textChanges {
|
||||
}
|
||||
}
|
||||
|
||||
function getInsertionPositionAtSourceFileTop({ text }: SourceFile): number {
|
||||
const shebang = getShebang(text);
|
||||
function getInsertionPositionAtSourceFileTop(sourceFile: SourceFile): number {
|
||||
let lastPrologue: PrologueDirective | undefined;
|
||||
for (const node of sourceFile.statements) {
|
||||
if (isPrologueDirective(node)) {
|
||||
lastPrologue = node;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let position = 0;
|
||||
const text = sourceFile.text;
|
||||
if (lastPrologue) {
|
||||
position = lastPrologue.end;
|
||||
advancePastLineBreak();
|
||||
return position;
|
||||
}
|
||||
|
||||
const shebang = getShebang(text);
|
||||
if (shebang !== undefined) {
|
||||
position = shebang.length;
|
||||
advancePastLineBreak();
|
||||
|
||||
Reference in new issue
Block a user