Skip to content

Commit 784bd0f

Browse files
committed
If there are no open files, do not schedule ensureProjectForOpenFiles
1 parent 566faa7 commit 784bd0f

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

src/server/editorServices.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ namespace ts.server {
930930

931931
/*@internal*/
932932
delayEnsureProjectForOpenFiles() {
933+
if (!this.openFiles.size) return;
933934
this.pendingEnsureProjectForOpenFiles = true;
934935
this.throttledOperations.schedule(ensureProjectForOpenFileSchedule, /*delay*/ 2500, () => {
935936
if (this.pendingProjectUpdates.size !== 0) {

src/testRunner/unittests/tsserver/externalProjects.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ namespace ts.projectSystem {
529529
[configFile.path]);
530530

531531
host.deleteFile(configFile.path);
532-
host.checkTimeoutQueueLengthAndRun(1);
533532

534533
knownProjects = projectService.synchronizeProjectList(map(knownProjects, proj => proj.info!)); // TODO: GH#18217 GH#20039
535534
checkNumberOfProjects(projectService, { configuredProjects: 0, externalProjects: 0, inferredProjects: 0 });

src/testRunner/unittests/tsserver/inferredProjects.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,5 +450,15 @@ namespace ts.projectSystem {
450450
};
451451
assert.deepEqual(inferredProject.getTypeAcquisition(), expected, "typeAcquisition should be inferred for inferred projects");
452452
});
453+
454+
it("Setting compiler options for inferred projects when there are no open files should not schedule any refresh", () => {
455+
const host = createServerHost([commonFile1, libFile]);
456+
const projectService = createProjectService(host);
457+
projectService.setCompilerOptionsForInferredProjects({
458+
allowJs: true,
459+
target: ScriptTarget.ES2015
460+
});
461+
host.checkTimeoutQueueLength(0);
462+
});
453463
});
454464
}

src/testRunner/unittests/tsserver/projects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ namespace ts.projectSystem {
419419
unresolvedImports: response.unresolvedImports,
420420
});
421421

422-
host.checkTimeoutQueueLengthAndRun(2);
422+
host.checkTimeoutQueueLengthAndRun(1);
423423
assert.isUndefined(request);
424424
});
425425

src/testRunner/unittests/tsserver/typingsInstaller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ namespace ts.projectSystem {
435435
installer.installAll(/*expectedCount*/ 1);
436436

437437
checkNumberOfProjects(projectService, { externalProjects: 1 });
438-
host.checkTimeoutQueueLengthAndRun(2);
438+
host.checkTimeoutQueueLengthAndRun(1);
439439
checkNumberOfProjects(projectService, { externalProjects: 1 });
440440
checkProjectActualFiles(p, [file2Jsx.path, file3dts.path, lodashDts.path, reactDts.path]);
441441
});
@@ -642,7 +642,7 @@ namespace ts.projectSystem {
642642
installer.installAll(/*expectedCount*/ 1);
643643

644644
checkNumberOfProjects(projectService, { externalProjects: 1 });
645-
host.checkTimeoutQueueLengthAndRun(2);
645+
host.checkTimeoutQueueLengthAndRun(1);
646646
checkNumberOfProjects(projectService, { externalProjects: 1 });
647647
// Commander: Existed as a JS file
648648
// JQuery: Specified in 'include'
@@ -726,7 +726,7 @@ namespace ts.projectSystem {
726726
for (const f of typingFiles) {
727727
assert.isTrue(host.fileExists(f.path), `expected file ${f.path} to exist`);
728728
}
729-
host.checkTimeoutQueueLengthAndRun(2);
729+
host.checkTimeoutQueueLengthAndRun(1);
730730
checkNumberOfProjects(projectService, { externalProjects: 1 });
731731
checkProjectActualFiles(p, [file3.path, commander.path, express.path, jquery.path, moment.path, lodash.path]);
732732
});
@@ -829,7 +829,7 @@ namespace ts.projectSystem {
829829
assert.equal(installer.pendingRunRequests.length, 0, "expected no throttled requests");
830830

831831
installer.executePendingCommands();
832-
host.checkTimeoutQueueLengthAndRun(3); // for 2 projects and 1 refreshing inferred project
832+
host.checkTimeoutQueueLengthAndRun(2); // for 2 projects
833833
checkProjectActualFiles(p1, [file3.path, commander.path, jquery.path, lodash.path, cordova.path]);
834834
checkProjectActualFiles(p2, [file3.path, grunt.path, gulp.path]);
835835
});

0 commit comments

Comments
 (0)