Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement cmake:hideBuildCommand context option. #1355

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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; }
}