Fix conversion of TextChanges to FileCodeEdits for new file (#24126)

This commit is contained in:
Andy
2018-05-15 13:55:26 -07:00
committed by GitHub
parent 86dce41ec0
commit cbbe34b35e
6 changed files with 25 additions and 8 deletions

View File

@@ -719,7 +719,7 @@ namespace ts.textChanges {
export function newFileChanges(oldFile: SourceFile, fileName: string, statements: ReadonlyArray<Statement>, newLineCharacter: string): FileTextChanges {
const text = statements.map(s => getNonformattedText(s, oldFile, newLineCharacter).text).join(newLineCharacter);
return { fileName, textChanges: [createTextChange(createTextSpan(0, 0), text)] };
return { fileName, textChanges: [createTextChange(createTextSpan(0, 0), text)], isNewFile: true };
}
function computeNewText(change: Change, sourceFile: SourceFile, newLineCharacter: string, formatContext: formatting.FormatContext, validate: ValidateNonFormattedText): string {

View File

@@ -439,6 +439,7 @@ namespace ts {
export interface FileTextChanges {
fileName: string;
textChanges: TextChange[];
isNewFile?: boolean;
}
export interface CodeAction {