From 40d9afc691cd04e12b19dd2dd376026befdd0890 Mon Sep 17 00:00:00 2001 From: Ufuk Kayserilioglu Date: Fri, 14 Jul 2023 00:50:07 +0300 Subject: [PATCH] Gracefully handle test commands run with no arguments If a test command is run with no arguments (for example, through a keybinding, or via the command palette), then we fall back to finding the correct arguments by finding the test item by active line. --- src/testController.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/testController.ts b/src/testController.ts index dc2ceba7..767c2757 100644 --- a/src/testController.ts +++ b/src/testController.ts @@ -152,6 +152,9 @@ export class TestController { _name: string, command: string ) { + // eslint-disable-next-line no-param-reassign + command ??= this.testCommands.get(this.findTestByActiveLine()!) || ""; + await this.telemetry.sendCodeLensEvent("test_in_terminal"); if (this.terminal === undefined) { @@ -276,6 +279,10 @@ export class TestController { testId: string, testItems: vscode.TestItemCollection = this.testController.items ) { + if (!testId) { + return this.findTestByActiveLine(); + } + let testItem = testItems.get(testId); if (testItem) return testItem;