Skip to content

Commit 8a559e4

Browse files
author
Andy
authored
Improve isNewFile assert (#25419)
1 parent 5e21027 commit 8a559e4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/server/session.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ namespace ts.server {
18371837
}
18381838

18391839
private mapTextChangeToCodeEdit(project: Project, change: FileTextChanges): protocol.FileCodeEdits {
1840-
return mapTextChangesToCodeEdits(change, project.getSourceFileOrConfigFile(this.normalizePath(change.fileName)));
1840+
return mapTextChangesToCodeEditsForFile(change, project.getSourceFileOrConfigFile(this.normalizePath(change.fileName)));
18411841
}
18421842

18431843
private mapTextChangeToCodeEditUsingScriptInfo(change: FileTextChanges): protocol.FileCodeEdits {
@@ -2357,8 +2357,8 @@ namespace ts.server {
23572357
return { file: fileName, start: scriptInfo.positionToLineOffset(textSpan.start), end: scriptInfo.positionToLineOffset(textSpanEnd(textSpan)) };
23582358
}
23592359

2360-
function mapTextChangesToCodeEdits(textChanges: FileTextChanges, sourceFile: SourceFile | undefined): protocol.FileCodeEdits {
2361-
Debug.assert(!!textChanges.isNewFile === !sourceFile);
2360+
function mapTextChangesToCodeEditsForFile(textChanges: FileTextChanges, sourceFile: SourceFile | undefined): protocol.FileCodeEdits {
2361+
Debug.assert(!!textChanges.isNewFile === !sourceFile, "Expected isNewFile for (only) new files", () => JSON.stringify({ isNewFile: textChanges.isNewFile, hasSourceFile: !!sourceFile }));
23622362
if (sourceFile) {
23632363
return {
23642364
fileName: textChanges.fileName,

0 commit comments

Comments
 (0)