diff --git a/package.json b/package.json index ea22eb8..9aa90eb 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "description": "Gauge support for VScode.", "author": "ThoughtWorks", "license": "MIT", - "version": "0.0.20", + "version": "0.0.21", "publisher": "getgauge", "engines": { "vscode": "^1.59.0" @@ -115,6 +115,18 @@ "dark": "resources/dark/play.svg" } }, + { + "command": "gauge.specexplorer.runNode", + "title": "Run", + "category": "Gauge", + "icon": "$(debug-start)" + }, + { + "command": "gauge.specexplorer.debugNode", + "title": "Debug", + "category": "Gauge", + "icon": "$(bug)" + }, { "command": "gauge.execute.scenario", "title": "Run Scenario", @@ -148,7 +160,7 @@ }, { "command": "gauge.specexplorer.switchProject", - "when": "false" + "when": "config.noExists" }, { "command": "gauge.execute.repeat", @@ -192,7 +204,15 @@ }, { "command": "gauge.specexplorer.runAllActiveProjectSpecs", - "when": "false" + "when": "config.noExists" + }, + { + "command": "gauge.specexplorer.runNode", + "when": "config.noExists" + }, + { + "command": "gauge.specexplorer.debugNode", + "when": "config.noExists" } ], "view/title": [ @@ -206,6 +226,18 @@ "when": "view == gauge:specExplorer", "group": "navigation" } + ], + "view/item/context": [ + { + "command": "gauge.specexplorer.runNode", + "when": "view == gauge:specExplorer", + "group": "inline" + }, + { + "command": "gauge.specexplorer.debugNode", + "when": "view == gauge:specExplorer", + "group": "inline" + } ] }, "configuration": { diff --git a/src/constants.ts b/src/constants.ts index cd398ba..7c61a5a 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -22,6 +22,8 @@ export enum GaugeVSCodeCommands { ExecuteSpec = 'gauge.execute.specification', ExecuteAllSpecs = 'gauge.execute.specification.all', ExecuteAllSpecExplorer = 'gauge.specexplorer.runAllActiveProjectSpecs', + ExecuteNode = 'gauge.specexplorer.runNode', + DebugNode = 'gauge.specexplorer.debugNode', ExecuteScenario = 'gauge.execute.scenario', ExecuteScenarios = 'gauge.execute.scenarios', GenerateStepStub = 'gauge.generate.step', diff --git a/src/execution/debug.ts b/src/execution/debug.ts index 3e20197..17d49e3 100644 --- a/src/execution/debug.ts +++ b/src/execution/debug.ts @@ -1,7 +1,7 @@ 'use strict'; import getPort = require('get-port'); -import { debug, DebugSession, window, workspace } from 'vscode'; +import { debug, DebugSession, Uri, workspace } from 'vscode'; import { GaugeRunners } from '../constants'; import { GaugeClients } from '../gaugeClients'; import { ExecutionConfig } from './executionConfig'; @@ -135,8 +135,8 @@ export class GaugeDebugger { public startDebugger() { return new Promise((res, rej) => { - let folder = workspace.getWorkspaceFolder(window.activeTextEditor.document.uri); - let root = this.clientsMap.get(window.activeTextEditor.document.uri.fsPath).project.root(); + const root = this.config.getProject().root(); + const folder = workspace.getWorkspaceFolder(Uri.parse(root)); if (!folder) { throw new Error(`The debugger does not work for a stand alone file. Please open the folder ${root}.`); } diff --git a/src/execution/lineProcessors.ts b/src/execution/lineProcessors.ts index 6a1c580..6fba5b2 100644 --- a/src/execution/lineProcessors.ts +++ b/src/execution/lineProcessors.ts @@ -44,8 +44,8 @@ export class DebuggerAttachedEventProcessor extends BaseProcessor { public process(lineText: string, gaugeDebugger: GaugeDebugger): void { if (!this.canProcess(lineText)) return; gaugeDebugger.addProcessId(+lineText.replace(/^\D+/g, '')); - gaugeDebugger.startDebugger().catch((reason) => { - window.showErrorMessage(reason); + gaugeDebugger.startDebugger().catch(error => { + window.showErrorMessage(`Failed to start debugger: ${error.message}`); this.executor.cancel(false); }); } diff --git a/src/explorer/specExplorer.ts b/src/explorer/specExplorer.ts index 0b7d3a5..aa79601 100644 --- a/src/explorer/specExplorer.ts +++ b/src/explorer/specExplorer.ts @@ -69,7 +69,21 @@ export class SpecNodeProvider extends Disposable implements vscode.TreeDataProvi }), commands.registerCommand(GaugeVSCodeCommands.Open, (node: GaugeNode) => workspace.openTextDocument(node.file) - .then(this.showDocumentWithSelection(node))) + .then(this.showDocumentWithSelection(node))), + + commands.registerCommand(GaugeVSCodeCommands.ExecuteNode, (node: GaugeNode) => + this.gaugeWorkspace.getGaugeExecutor().execute( + node instanceof Scenario ? node.executionIdentifier : node.file, + new ExecutionConfig().setStatus(node.file) + .setProject(this.gaugeWorkspace.getClientsMap().get(node.file).project)) + ), + + commands.registerCommand(GaugeVSCodeCommands.DebugNode, (node: GaugeNode) => + this.gaugeWorkspace.getGaugeExecutor().execute( + node instanceof Scenario ? node.executionIdentifier : node.file, + new ExecutionConfig().setStatus(node.file).setDebug() + .setProject(this.gaugeWorkspace.getClientsMap().get(node.file).project)) + ) ); } }