Report file change detected only once when save takes place multiple times before timeout

This commit is contained in:
Sheetal Nandi 2018-08-30 11:38:34 -07:00
parent 828279b611
commit 496b18ef5e
2 changed files with 19 additions and 1 deletions

View File

@ -507,6 +507,7 @@ namespace ts {
const configFileCache = createConfigFileCache(host);
let context = createBuildContext(defaultOptions);
let timerToBuildInvalidatedProject: any;
let reportFileChangeDetected = false;
const existingWatchersForWildcards = createMap<WildcardDirectoryWatcher>();
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()) {

View File

@ -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, [