From 14ca4dd621254bb2b8fd15e277e482af0e28ebb7 Mon Sep 17 00:00:00 2001 From: Yan Zhang Date: Fri, 4 Jan 2019 15:01:53 +0800 Subject: [PATCH] Fix project view for multiroot workspaces. (#211) --- src/explorer/model/WorkspaceFolder.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/explorer/model/WorkspaceFolder.ts b/src/explorer/model/WorkspaceFolder.ts index 279a2aa1..6cf13e41 100644 --- a/src/explorer/model/WorkspaceFolder.ts +++ b/src/explorer/model/WorkspaceFolder.ts @@ -24,12 +24,17 @@ export class WorkspaceFolder implements ITreeItem { public async getChildren(): Promise { const newProjects: MavenProject[] = []; + const allProjects: MavenProject[] = []; const pomPaths: string[] = await Utils.getAllPomPaths(this._workspaceFolder); for (const pomPath of pomPaths) { - if (!mavenExplorerProvider.getMavenProject(pomPath)) { - newProjects.push(new MavenProject(pomPath)); + let currentProject: MavenProject = mavenExplorerProvider.getMavenProject(pomPath); + if (!currentProject) { + currentProject = new MavenProject(pomPath); + newProjects.push(currentProject); } + allProjects.push(currentProject); } + await Promise.all(newProjects.map(elem => elem.parsePom())); mavenExplorerProvider.updateProjects(...newProjects); newProjects.forEach(p => { @@ -41,8 +46,7 @@ export class WorkspaceFolder implements ITreeItem { }); }); - const allProjectNodes: MavenProject[] = mavenExplorerProvider.mavenProjectNodes; - if (allProjectNodes.length === 0) { + if (allProjects.length === 0) { return [{ getTreeItem: () => new vscode.TreeItem("No Maven project found."), getContextValue: () => "EmptyNode" @@ -51,9 +55,9 @@ export class WorkspaceFolder implements ITreeItem { switch (Settings.viewType()) { case "hierarchical": - return this.sortByName(allProjectNodes.filter(m => !m.parent)); + return this.sortByName(allProjects.filter(m => !m.parent)); case "flat": - return this.sortByName(allProjectNodes); + return this.sortByName(allProjects); default: return null; } }