From 9b2e2d590b8f3cf34fe87819ade781eac1d705dc Mon Sep 17 00:00:00 2001 From: Nathan Esau Date: Fri, 12 Jun 2020 17:51:10 -0400 Subject: [PATCH 1/3] add re-run last test option --- src/commands/test.ts | 14 ++++++++++++++ src/leetCodeExecutor.ts | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/src/commands/test.ts b/src/commands/test.ts index d070c9aa..5f97981f 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -42,6 +42,12 @@ export async function testSolution(uri?: vscode.Uri): Promise { detail: "Test with the written cases in file", value: ":file", }, + { + label: "$(refresh) Re- run last...", + description: "", + detail: "Test with the cases which were last run", + value: ":rerun" + } ); const choice: IQuickItemEx | undefined = await vscode.window.showQuickPick(picks); if (!choice) { @@ -75,6 +81,14 @@ export async function testSolution(uri?: vscode.Uri): Promise { } } break; + case ":rerun": + if (leetCodeExecutor.lastTestString) { + result = await leetCodeExecutor.testSolution(filePath, leetCodeExecutor.lastTestString); + } + else { // run default cases + result = await leetCodeExecutor.testSolution(filePath); + } + break; default: break; } diff --git a/src/leetCodeExecutor.ts b/src/leetCodeExecutor.ts index 4c0aa312..c23c6861 100644 --- a/src/leetCodeExecutor.ts +++ b/src/leetCodeExecutor.ts @@ -15,11 +15,13 @@ import { toWslPath, useWsl } from "./utils/wslUtils"; class LeetCodeExecutor implements Disposable { private leetCodeRootPath: string; private nodeExecutable: string; + private lastTest: string | undefined; private configurationChangeListener: Disposable; constructor() { this.leetCodeRootPath = path.join(__dirname, "..", "..", "node_modules", "vsc-leetcode-cli"); this.nodeExecutable = this.getNodePath(); + this.lastTest = ""; this.configurationChangeListener = workspace.onDidChangeConfiguration((event: ConfigurationChangeEvent) => { if (event.affectsConfiguration("leetcode.nodePath")) { this.nodeExecutable = this.getNodePath(); @@ -133,6 +135,7 @@ class LeetCodeExecutor implements Disposable { } public async testSolution(filePath: string, testString?: string): Promise { + this.lastTest = testString; if (testString) { return await this.executeCommandWithProgressEx("Submitting to LeetCode...", this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "test", `"${filePath}"`, "-t", `${testString}`]); } @@ -172,6 +175,10 @@ class LeetCodeExecutor implements Disposable { return this.nodeExecutable; } + public get lastTestString(): string | undefined { + return this.lastTest; + } + public dispose(): void { this.configurationChangeListener.dispose(); } From 41baf49f57a0368f3609ab8ab47bde569ea78c67 Mon Sep 17 00:00:00 2001 From: Nathan Esau Date: Fri, 12 Jun 2020 17:56:34 -0400 Subject: [PATCH 2/3] fix lint problems --- src/commands/test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/commands/test.ts b/src/commands/test.ts index 5f97981f..0d08327b 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -46,8 +46,8 @@ export async function testSolution(uri?: vscode.Uri): Promise { label: "$(refresh) Re- run last...", description: "", detail: "Test with the cases which were last run", - value: ":rerun" - } + value: ":rerun", + }, ); const choice: IQuickItemEx | undefined = await vscode.window.showQuickPick(picks); if (!choice) { @@ -84,8 +84,7 @@ export async function testSolution(uri?: vscode.Uri): Promise { case ":rerun": if (leetCodeExecutor.lastTestString) { result = await leetCodeExecutor.testSolution(filePath, leetCodeExecutor.lastTestString); - } - else { // run default cases + } else { // run default cases result = await leetCodeExecutor.testSolution(filePath); } break; From f7fbbec72caaeefe3606c059cc8684de3848d55d Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Thu, 23 Jul 2020 08:48:59 -0400 Subject: [PATCH 3/3] use debug-restart icon --- src/commands/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/test.ts b/src/commands/test.ts index 0d08327b..152f0976 100644 --- a/src/commands/test.ts +++ b/src/commands/test.ts @@ -43,7 +43,7 @@ export async function testSolution(uri?: vscode.Uri): Promise { value: ":file", }, { - label: "$(refresh) Re- run last...", + label: "$(debug-restart) Re-run last...", description: "", detail: "Test with the cases which were last run", value: ":rerun",