Skip to content

Commit 8d6c2bc

Browse files
author
Josh Goldberg
committed
Used return value from clearScreenIfNotWatchingForFiles
1 parent d1b044b commit 8d6c2bc

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/compiler/watch.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ namespace ts {
3434
Diagnostics.Found_0_errors.code
3535
];
3636

37-
function clearScreenIfNotWatchingForFileChanges(system: System, diagnostic: Diagnostic, options: CompilerOptions) {
37+
/**
38+
* @returns Whether the screen was cleared.
39+
*/
40+
function clearScreenIfNotWatchingForFileChanges(system: System, diagnostic: Diagnostic, options: CompilerOptions): boolean {
3841
if (system.clearScreen &&
3942
!options.preserveWatchOutput &&
4043
!options.extendedDiagnostics &&
4144
!options.diagnostics &&
4245
!contains(nonClearingMessageCodes, diagnostic.code)) {
4346
system.clearScreen();
47+
return true;
4448
}
49+
50+
return false;
4551
}
4652

4753
/** @internal */
@@ -50,12 +56,6 @@ namespace ts {
5056
Diagnostics.File_change_detected_Starting_incremental_compilation.code,
5157
];
5258

53-
function getPlainDiagnosticPrecedingNewLines(diagnostic: Diagnostic, newLine: string, preserveWatchOutput?: boolean): string {
54-
return !preserveWatchOutput && contains(screenStartingMessageCodes, diagnostic.code)
55-
? ""
56-
: newLine;
57-
}
58-
5959
function getPlainDiagnosticFollowingNewLines(diagnostic: Diagnostic, newLine: string): string {
6060
return contains(screenStartingMessageCodes, diagnostic.code)
6161
? newLine + newLine
@@ -74,8 +74,10 @@ namespace ts {
7474
system.write(output);
7575
} :
7676
(diagnostic, newLine, options) => {
77-
clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
78-
let output = `${getPlainDiagnosticPrecedingNewLines(diagnostic, newLine, options.preserveWatchOutput)}${new Date().toLocaleTimeString()} - `;
77+
if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
78+
system.write(newLine);
79+
}
80+
let output = `${new Date().toLocaleTimeString()} - `;
7981
output += `${flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)}${getPlainDiagnosticFollowingNewLines(diagnostic, newLine)}`;
8082
system.write(output);
8183
};

0 commit comments

Comments
 (0)