diff --git a/src/commands/submit.ts b/src/commands/submit.ts index f6e2d989..26660029 100644 --- a/src/commands/submit.ts +++ b/src/commands/submit.ts @@ -2,6 +2,7 @@ // Licensed under the MIT license. import * as vscode from "vscode"; +import { leetCodeTreeDataProvider } from "../explorer/LeetCodeTreeDataProvider"; import { leetCodeExecutor } from "../leetCodeExecutor"; import { leetCodeManager } from "../leetCodeManager"; import { DialogType, promptForOpenOutputChannel, promptForSignIn } from "../utils/uiUtils"; @@ -24,5 +25,8 @@ export async function submitSolution(uri?: vscode.Uri): Promise { leetCodeSubmissionProvider.show(result); } catch (error) { await promptForOpenOutputChannel("Failed to submit the solution. Please open the output channel for details.", DialogType.error); + return; } + + leetCodeTreeDataProvider.refresh(); } diff --git a/src/explorer/LeetCodeTreeDataProvider.ts b/src/explorer/LeetCodeTreeDataProvider.ts index a4339614..ac115424 100644 --- a/src/explorer/LeetCodeTreeDataProvider.ts +++ b/src/explorer/LeetCodeTreeDataProvider.ts @@ -11,11 +11,15 @@ import { LeetCodeNode } from "./LeetCodeNode"; export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider { - private onDidChangeTreeDataEvent: vscode.EventEmitter = new vscode.EventEmitter(); + private context: vscode.ExtensionContext; + + private onDidChangeTreeDataEvent: vscode.EventEmitter = new vscode.EventEmitter(); // tslint:disable-next-line:member-ordering public readonly onDidChangeTreeData: vscode.Event = this.onDidChangeTreeDataEvent.event; - constructor(private context: vscode.ExtensionContext) { } + public initialize(context: vscode.ExtensionContext): void { + this.context = context; + } public async refresh(): Promise { await explorerNodeManager.refreshCache(); @@ -26,7 +30,6 @@ export class LeetCodeTreeDataProvider implements vscode.TreeDataProvider leetCodeTreeDataProvider.refresh(); }); - const leetCodeTreeDataProvider: LeetCodeTreeDataProvider = new LeetCodeTreeDataProvider(context); + leetCodeTreeDataProvider.initialize(context); context.subscriptions.push( leetCodeStatusBarController,