Skip to content

Commit cf70dcd

Browse files
Vigilanstestforstephen
authored andcommitted
Use local variable to avoid concurrent modification (#182)
1 parent 4d23f2b commit cf70dcd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/views/dependencyDataProvider.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,24 @@ export class DependencyDataProvider implements TreeDataProvider<ExplorerNode> {
9999

100100
private getRootNodes(): Thenable<ExplorerNode[]> {
101101
return new Promise((resolve, reject) => {
102-
this._rootItems = new Array<ExplorerNode>();
102+
const rootItems = new Array<ExplorerNode>();
103103
const folders = workspace.workspaceFolders;
104104
if (folders && folders.length) {
105105
if (folders.length > 1) {
106-
folders.forEach((folder) => this._rootItems.push(new WorkspaceNode({
106+
folders.forEach((folder) => rootItems.push(new WorkspaceNode({
107107
name: folder.name,
108108
uri: folder.uri.toString(),
109109
kind: NodeKind.Workspace,
110110
}, null)));
111-
resolve(this._rootItems);
111+
this._rootItems = rootItems;
112+
resolve(rootItems);
112113
} else {
113114
Jdtls.getProjects(folders[0].uri.toString()).then((result: INodeData[]) => {
114115
result.forEach((project) => {
115-
this._rootItems.push(new ProjectNode(project, null));
116+
rootItems.push(new ProjectNode(project, null));
116117
});
117-
resolve(this._rootItems);
118+
this._rootItems = rootItems;
119+
resolve(rootItems);
118120
});
119121
}
120122
} else {

0 commit comments

Comments
 (0)