Skip to content

Commit

Permalink
fix the bug that explorer has duplicate nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo committed Feb 22, 2018
1 parent 7d619b3 commit 8024c3d
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/leetCodeExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
constructor(private context: vscode.ExtensionContext, private channel: vscode.OutputChannel) { }

public async refresh(): Promise<void> {
this.treeData.clear();
await this.getProblemData();
this.onDidChangeTreeDataEvent.fire();
}
Expand Down Expand Up @@ -100,14 +99,14 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod

private async getProblemData(): Promise<void> {
const allProblems: list.IProblem[] = await list.listProblems(this.channel);
this.treeData.clear();
for (const problem of allProblems) {
const problems: list.IProblem[] | undefined = this.treeData.get(problem.difficulty);
if (problems) {
problems.push(problem);
} else {
this.treeData.set(problem.difficulty, [problem]);
}

}
}

Expand Down Expand Up @@ -156,5 +155,4 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider<LeetCod
});
return difficultynodes;
}

}

0 comments on commit 8024c3d

Please sign in to comment.