Remove the configured project if on next open file if it has no open files instead of immediately when closing last open file

This commit is contained in:
Sheetal Nandi 2017-08-31 17:58:09 -07:00
parent 8d5d4c2a0e
commit 9e5e20c80f
2 changed files with 17 additions and 4 deletions

View File

@ -878,10 +878,10 @@ namespace ts.server {
if (info.hasMixedContent) {
info.registerFileUpdate();
}
// last open file in configured project - close it
if ((<ConfiguredProject>p).deleteOpenRef() === 0) {
(projectsToRemove || (projectsToRemove = [])).push(p);
}
// Delete the reference to the open configured projects but
// do not remove the project so that we can reuse this project
// if it would need to be re-created with next file open
(<ConfiguredProject>p).deleteOpenRef();
}
else if (p.projectKind === ProjectKind.Inferred && p.isRoot(info)) {
// If this was the open root file of inferred project
@ -1881,6 +1881,15 @@ namespace ts.server {
}
this.addToListOfOpenFiles(info);
// Remove the configured projects that have zero references from open files.
// This was postponed from closeOpenFile to after opening next file,
// so that we can reuse the project if we need to right away
this.configuredProjects.forEach(project => {
if (!project.hasOpenRef()) {
this.removeProject(project);
}
});
// Delete the orphan files here because there might be orphan script infos (which are not part of project)
// when some file/s were closed which resulted in project removal.
// It was then postponed to cleanup these script infos so that they can be reused if

View File

@ -1311,6 +1311,10 @@ namespace ts.server {
return this.openRefCount;
}
hasOpenRef() {
return !!this.openRefCount;
}
getEffectiveTypeRoots() {
return getEffectiveTypeRoots(this.getCompilationSettings(), this.partialSystem) || [];
}