mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
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:
parent
8d5d4c2a0e
commit
9e5e20c80f
@ -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
|
||||
|
||||
@ -1311,6 +1311,10 @@ namespace ts.server {
|
||||
return this.openRefCount;
|
||||
}
|
||||
|
||||
hasOpenRef() {
|
||||
return !!this.openRefCount;
|
||||
}
|
||||
|
||||
getEffectiveTypeRoots() {
|
||||
return getEffectiveTypeRoots(this.getCompilationSettings(), this.partialSystem) || [];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user