From 775f4ccdd402f8c0151c972919ba5e48f4ccfc08 Mon Sep 17 00:00:00 2001 From: elrashed Date: Wed, 1 Mar 2023 10:14:03 -0800 Subject: [PATCH] fix stop commands --- package.json | 11 ++++++++--- src/proc.ts | 2 +- src/sideBar.ts | 48 ++++++++++++++++++++---------------------------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index f7ec8818..a12e7217 100644 --- a/package.json +++ b/package.json @@ -1027,20 +1027,25 @@ } ], "view/title": [ + { + "command": "cmake.projectStatus.stop", + "when": "view == cmake.projectStatus && cmake:isBuilding && cmake:enableFullFeatureSet", + "group": "navigation@1" + }, { "command": "cmake.projectStatus.update", "when": "view == cmake.projectStatus && cmake:enableFullFeatureSet", - "group": "navigation@1" + "group": "navigation@2" }, { "command": "cmake.projectStatus.debugTarget", "when": "view == cmake.projectStatus && !cmake:hideDebugCommand && cmake:enableFullFeatureSet", - "group": "navigation@2" + "group": "navigation@3" }, { "command": "cmake.projectStatus.launchTarget", "when": "view == cmake.projectStatus && !cmake:hideLaunchCommand && cmake:enableFullFeatureSet", - "group": "navigation@2" + "group": "navigation@3" }, { "command": "cmake.outline.configureAll", diff --git a/src/proc.ts b/src/proc.ts index 6061eee0..8abd0e83 100644 --- a/src/proc.ts +++ b/src/proc.ts @@ -142,7 +142,7 @@ export function execute(command: string, args?: string[], outputConsumer?: Outpu // and doesn't have to be 100% correct. localize('executing.command', 'Executing command: {0}', cmdstr)); if (options.environment) { - log.debug(localize('execution.environment', ' with environment: {0}', JSON.stringify(final_env))); + //log.debug(localize('execution.environment', ' with environment: {0}', JSON.stringify(final_env))); } } const spawn_opts: proc.SpawnOptions = { diff --git a/src/sideBar.ts b/src/sideBar.ts index c3df1e8e..55ed107a 100644 --- a/src/sideBar.ts +++ b/src/sideBar.ts @@ -72,9 +72,8 @@ class TreeDataProvider implements vscode.TreeDataProvider, vscode.Disposab this.disposables.push(...[ this.treeView, // Commands for projectStatus items - vscode.commands.registerCommand('cmake.projectStatus.stop', async (node: Node) => { - await runCommand('stop'); - await this.refresh(node); + vscode.commands.registerCommand('cmake.projectStatus.stop', async () => { + runCommand('stop'); }), vscode.commands.registerCommand('cmake.projectStatus.selectKit', async (node: Node) => { await runCommand('selectKit'); @@ -84,23 +83,15 @@ class TreeDataProvider implements vscode.TreeDataProvider, vscode.Disposab await runCommand('selectConfigurePreset', folder); await this.refresh(node); }), - vscode.commands.registerCommand('cmake.projectStatus.configure', async (node: Node, folder: vscode.WorkspaceFolder) => { - node.changeToStop(); - await this.refresh(node); - await runCommand('configure', folder); - node.changeBackToOriginal(); - await this.refresh(node); + vscode.commands.registerCommand('cmake.projectStatus.configure', async (folder: vscode.WorkspaceFolder) => { + runCommand('configure', folder); }), vscode.commands.registerCommand('cmake.projectStatus.setVariant', async (node: Node, folder: vscode.WorkspaceFolder, variant: Promise) => { await runCommand('setVariant', folder, await variant); await this.refresh(node); }), - vscode.commands.registerCommand('cmake.projectStatus.build', async (node: Node, folder: vscode.WorkspaceFolder, target: Promise) => { - node.changeToStop(); - await this.refresh(node); - await runCommand('build', folder, await target); - node.changeBackToOriginal(); - await this.refresh(node); + vscode.commands.registerCommand('cmake.projectStatus.build', async (folder: vscode.WorkspaceFolder, target: Promise) => { + runCommand('build', folder, await target); }), vscode.commands.registerCommand('cmake.projectStatus.setDefaultTarget', async (node: Node, folder: vscode.WorkspaceFolder, target: Promise) => { await runCommand('setDefaultTarget', folder, await target); @@ -182,10 +173,16 @@ class TreeDataProvider implements vscode.TreeDataProvider, vscode.Disposab let nodes: Node[] = []; const configNode = new ConfigNode(); await configNode.initialize(); + if (this.isBusy) { + configNode.convertToStopCommand(); + } nodes.push(configNode); if (!this.isBuildButtonHidden) { const buildNode = new BuildNode(); await buildNode.initialize(); + if (this.isBusy) { + buildNode.convertToStopCommand(); + } nodes.push(buildNode); } const testNode = new TestNode(); @@ -232,11 +229,6 @@ class TreeDataProvider implements vscode.TreeDataProvider, vscode.Disposab setIsBusy(isBusy: boolean) { if (this.isBusy != isBusy) { this.isBusy = isBusy; - if (isBusy) { - - } else { - - } this.refresh(); } } @@ -263,10 +255,10 @@ class Node extends vscode.TreeItem { async refresh(): Promise { } - changeToStop(): void { + convertToStopCommand(): void { } - changeBackToOriginal(): void { + convertToOriginalCommand(): void { } } @@ -284,7 +276,7 @@ class ConfigNode extends Node { this.command = { title: this.label, command: 'cmake.projectStatus.configure', - arguments: [this, treeDataProvider.cmakeProject.workspaceFolder] + arguments: [treeDataProvider.cmakeProject.workspaceFolder] }; this.tooltip = this.label; this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded; @@ -318,7 +310,7 @@ class ConfigNode extends Node { } } - changeToStop(): void { + convertToStopCommand(): void { this.label = localize("configure.running", "Configure (Running)"); const title: string = localize('Stop', 'Stop'); this.command = { @@ -330,7 +322,7 @@ class ConfigNode extends Node { this.contextValue = "stop"; } - changeBackToOriginal(): Promise { + convertToOriginalCommand(): Promise { return this.initialize(); } @@ -349,7 +341,7 @@ class BuildNode extends Node { this.command = { title: this.label, command: 'cmake.projectStatus.build', - arguments: [this, treeDataProvider.cmakeProject.workspaceFolder, treeDataProvider.cmakeProject.buildTargetName()] + arguments: [treeDataProvider.cmakeProject.workspaceFolder, treeDataProvider.cmakeProject.buildTargetName()] }; this.tooltip = this.label; this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded; @@ -381,7 +373,7 @@ class BuildNode extends Node { } } - changeToStop(): void { + convertToStopCommand(): void { this.label = localize("build.running", "Build (Running)"); const title: string = localize('Stop', 'Stop'); this.command = { @@ -393,7 +385,7 @@ class BuildNode extends Node { this.contextValue = "stop"; } - changeBackToOriginal(): Promise { + convertToOriginalCommand(): Promise { return this.initialize(); }