From 496b18ef5e1187d03311b0f98772cf64c9637551 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 30 Aug 2018 11:38:34 -0700 Subject: [PATCH] Report file change detected only once when save takes place multiple times before timeout --- src/compiler/tsbuild.ts | 7 ++++++- src/testRunner/unittests/tsbuildWatchMode.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 95beb65e28ee3..4ddda98a41fd4 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -507,6 +507,7 @@ namespace ts { const configFileCache = createConfigFileCache(host); let context = createBuildContext(defaultOptions); let timerToBuildInvalidatedProject: any; + let reportFileChangeDetected = false; const existingWatchersForWildcards = createMap(); return { @@ -584,7 +585,7 @@ namespace ts { } function invalidateProjectAndScheduleBuilds(resolved: ResolvedConfigFileName) { - reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation); + reportFileChangeDetected = true; invalidateProject(resolved); scheduleBuildInvalidatedProject(); } @@ -817,6 +818,10 @@ namespace ts { function buildInvalidatedProject() { timerToBuildInvalidatedProject = undefined; + if (reportFileChangeDetected) { + reportFileChangeDetected = false; + reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation); + } const buildProject = context.getNextInvalidatedProject(); buildSomeProjects(p => p === buildProject); if (context.hasPendingInvalidatedProjects()) { diff --git a/src/testRunner/unittests/tsbuildWatchMode.ts b/src/testRunner/unittests/tsbuildWatchMode.ts index b788435006145..daa1276e0236d 100644 --- a/src/testRunner/unittests/tsbuildWatchMode.ts +++ b/src/testRunner/unittests/tsbuildWatchMode.ts @@ -112,9 +112,22 @@ export class someClass { }`); // Another change requeues and builds it verifyChange(core[1].content); + // Two changes together report only single time message: File change detected. Starting incremental compilation... + const outputFileStamps = getOutputFileStamps(host); + const change1 = `${core[1].content} +export class someClass { }`; + host.writeFile(core[1].path, change1); + host.writeFile(core[1].path, `${change1} +export class someClass2 { }`); + verifyChangeAfterTimeout(outputFileStamps); + function verifyChange(coreContent: string) { const outputFileStamps = getOutputFileStamps(host); host.writeFile(core[1].path, coreContent); + verifyChangeAfterTimeout(outputFileStamps); + } + + function verifyChangeAfterTimeout(outputFileStamps: OutputFileStamp[]) { host.checkTimeoutQueueLengthAndRun(1); // Builds core const changedCore = getOutputFileStamps(host); verifyChangedFiles(changedCore, outputFileStamps, [