Do not remove inferred project immediately and try to reuse it on next file open

This commit is contained in:
Sheetal Nandi
2018-04-20 13:38:15 -07:00
parent 616458261c
commit d6dfd9a217
6 changed files with 225 additions and 107 deletions

View File

@@ -591,6 +591,11 @@ namespace ts.server {
return this.rootFiles && this.rootFiles.length > 0;
}
/*@internal*/
isOrphan() {
return false;
}
getRootFiles() {
return this.rootFiles && this.rootFiles.map(info => info.fileName);
}
@@ -1173,6 +1178,10 @@ namespace ts.server {
/** this is canonical project root path */
readonly projectRootPath: string | undefined;
/*@internal*/
/** stored only if their is no projectRootPath and this isnt single inferred project */
readonly canonicalCurrentDirectory: string | undefined;
/*@internal*/
constructor(
projectService: ProjectService,
@@ -1191,6 +1200,9 @@ namespace ts.server {
projectService.host,
currentDirectory);
this.projectRootPath = projectRootPath && projectService.toCanonicalFileName(projectRootPath);
if (!projectRootPath && !projectService.useSingleInferredProject) {
this.canonicalCurrentDirectory = projectService.toCanonicalFileName(this.currentDirectory);
}
this.enableGlobalPlugins();
}
@@ -1213,6 +1225,11 @@ namespace ts.server {
}
}
/*@internal*/
isOrphan() {
return !this.hasRoots();
}
isProjectWithSingleRoot() {
// - when useSingleInferredProject is not set and projectRootPath is not set,
// we can guarantee that this will be the only root