Skip to content

Commit 8bcca68

Browse files
committed
[in progress] project system work - fixes in tests 2
1 parent 4157655 commit 8bcca68

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

src/server/editorServices.ts

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -376,30 +376,35 @@ namespace ts.server {
376376
}
377377
return;
378378
}
379+
if (info.containingProjects.length === 0) {
380+
// create new inferred project p with the newly opened file as root
381+
const inferredProject = this.createAndAddInferredProject(info);
382+
const openFileRoots: ScriptInfo[] = [];
383+
// for each inferred project root r
384+
for (const rootFile of this.openFileRoots) {
385+
// if r referenced by the new project
386+
if (inferredProject.containsScriptInfo(rootFile)) {
387+
// remove inferred project that was initially created for rootFile
388+
const defaultProject = rootFile.getDefaultProject();
389+
if (defaultProject === inferredProject) {
390+
continue;
391+
}
392+
Debug.assert(defaultProject.projectKind === ProjectKind.Inferred);
379393

380-
// create new inferred project p with the newly opened file as root
381-
const inferredProject = this.createAndAddInferredProject(info);
382-
const openFileRoots: ScriptInfo[] = [];
383-
// for each inferred project root r
384-
for (const rootFile of this.openFileRoots) {
385-
// if r referenced by the new project
386-
if (inferredProject.containsScriptInfo(rootFile)) {
387-
// remove inferred project that was initially created for rootFile
388-
const defaultProject = rootFile.getDefaultProject();
389-
Debug.assert(defaultProject.projectKind === ProjectKind.Inferred);
390-
391-
this.removeProject(defaultProject);
392-
// put r in referenced open file list
393-
this.openFilesReferenced.push(rootFile);
394-
// set default project of r to the new project
395-
rootFile.attachToProject(inferredProject);
396-
}
397-
else {
398-
// otherwise, keep r as root of inferred project
399-
openFileRoots.push(rootFile);
394+
this.removeProject(defaultProject);
395+
// put r in referenced open file list
396+
this.openFilesReferenced.push(rootFile);
397+
// set default project of r to the new project
398+
rootFile.attachToProject(inferredProject);
399+
}
400+
else {
401+
// otherwise, keep r as root of inferred project
402+
openFileRoots.push(rootFile);
403+
}
400404
}
405+
this.openFileRoots = openFileRoots;
401406
}
402-
this.openFileRoots = openFileRoots;
407+
403408
this.openFileRoots.push(info);
404409
}
405410

0 commit comments

Comments
 (0)