Skip to content

Commit

Permalink
Implement cmake.hideBuildCommand context option. (#1355)
Browse files Browse the repository at this point in the history
Co-authored-by: Andreea Isac <[email protected]>
  • Loading branch information
tritao and andreeis authored Oct 7, 2020
1 parent 4c3b678 commit fadc2c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1492,12 +1492,12 @@
"keybindings": [
{
"key": "f7",
"when": "cmake:enableFullFeatureSet",
"when": "!cmake:hideBuildCommand && cmake:enableFullFeatureSet",
"command": "cmake.build"
},
{
"key": "shift+f7",
"when": "cmake:enableFullFeatureSet",
"when": "!cmake:hideBuildCommand && cmake:enableFullFeatureSet",
"command": "cmake.buildWithTarget"
},
{
Expand Down
9 changes: 8 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const log = logging.createLogger('extension');
const MULTI_ROOT_MODE_KEY = 'cmake:multiRoot';
const HIDE_LAUNCH_COMMAND_KEY = 'cmake:hideLaunchCommand';
const HIDE_DEBUG_COMMAND_KEY = 'cmake:hideDebugCommand';
const HIDE_BUILD_COMMAND_KEY = 'cmake:hideBuildCommand';

type CMakeToolsMapFn = (cmt: CMakeTools) => Thenable<any>;
type CMakeToolsQueryMapFn = (cmt: CMakeTools) => Thenable<string | string[] | null>;
Expand Down Expand Up @@ -941,6 +942,11 @@ class ExtensionManager implements vscode.Disposable {
await util.setContextValue(HIDE_DEBUG_COMMAND_KEY, shouldHide);
}

async hideBuildCommand(shouldHide: boolean = true) {
this._statusBar.hideBuildButton(shouldHide);
await util.setContextValue(HIDE_BUILD_COMMAND_KEY, shouldHide);
}

// Helper that loops through all the workspace folders to enable full or partial feature set
// depending on their 'ignoreCMakeListsMissing' state variable.
enableWorkspaceFoldersFullFeatureSet() {
Expand Down Expand Up @@ -1042,7 +1048,8 @@ async function setup(context: vscode.ExtensionContext, progress: ProgressHandle)
'selectWorkspace',
'tasksBuildCommand',
'hideLaunchCommand',
'hideDebugCommand'
'hideDebugCommand',
'hideBuildCommand'
// 'toggleCoverageDecorations', // XXX: Should coverage decorations be revived?
];

Expand Down
9 changes: 8 additions & 1 deletion src/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ class BuildButton extends Button {

private _isBusy: boolean = false;
private _target: string|null = null;
private _hidden: boolean = false;

set hidden(v: boolean) {
this._hidden = v;
this.update();
}

set isBusy(v: boolean) {
this._isBusy = v;
Expand All @@ -417,7 +423,7 @@ class BuildButton extends Button {
}
protected getTooltipShort(): string|null { return this.prependCMake(this.getTooltipNormal()); }

protected isVisible(): boolean { return this._isBusy || true; }
protected isVisible(): boolean { return !this._hidden && (this._isBusy || true); }
}

export class StatusBar implements vscode.Disposable {
Expand Down Expand Up @@ -480,4 +486,5 @@ export class StatusBar implements vscode.Disposable {

hideLaunchButton(shouldHide: boolean = true): void { this._launchButton.hidden = shouldHide; }
hideDebugButton(shouldHide: boolean = true): void { this._debugButton.hidden = shouldHide; }
hideBuildButton(shouldHide: boolean = true): void { this._buildButton.hidden = shouldHide; }
}

0 comments on commit fadc2c2

Please sign in to comment.