Skip to content

Commit c7119ae

Browse files
authored
Merge pull request #125679 from microsoft/isidorn/fixRunMenu
better context key for run menu
2 parents 0ef242c + 6d4a8af commit c7119ae

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/vs/workbench/browser/parts/titlebar/menubarControl.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { localize } from 'vs/nls';
77
import { IMenuService, MenuId, IMenu, SubmenuItemAction, registerAction2, Action2, MenuItemAction, MenuRegistry } from 'vs/platform/actions/common/actions';
88
import { registerThemingParticipant, IThemeService } from 'vs/platform/theme/common/themeService';
99
import { MenuBarVisibility, getTitleBarStyle, IWindowOpenable, getMenuBarVisibility } from 'vs/platform/windows/common/windows';
10-
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
10+
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1111
import { IAction, Action, SubmenuAction, Separator } from 'vs/base/common/actions';
1212
import { addDisposableListener, Dimension, EventType } from 'vs/base/browser/dom';
1313
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@@ -98,7 +98,8 @@ MenuRegistry.appendMenuItem(MenuId.MenubarMainMenu, {
9898
original: 'Terminal',
9999
mnemonicTitle: localize({ key: 'mTerminal', comment: ['&& denotes a mnemonic'] }, "&&Terminal")
100100
},
101-
order: 7
101+
order: 7,
102+
when: ContextKeyExpr.has('terminalProcessSupported')
102103
});
103104

104105
MenuRegistry.appendMenuItem(MenuId.MenubarMainMenu, {

src/vs/workbench/contrib/debug/browser/debug.contribution.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import { registerColors } from 'vs/workbench/contrib/debug/browser/debugColors';
5050
import { DebugEditorContribution } from 'vs/workbench/contrib/debug/browser/debugEditorContribution';
5151
import { FileAccess } from 'vs/base/common/network';
5252
import * as icons from 'vs/workbench/contrib/debug/browser/debugIcons';
53-
import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
5453

5554
const debugCategory = nls.localize('debugCategory', "Debug");
5655
registerColors();
@@ -186,7 +185,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarMainMenu, {
186185
original: 'Run',
187186
mnemonicTitle: nls.localize({ key: 'mRun', comment: ['&& denotes a mnemonic'] }, "&&Run")
188187
},
189-
when: ContextKeyExpr.or(CONTEXT_DEBUGGERS_AVAILABLE, IsWebContext.toNegated()),
188+
when: ContextKeyExpr.or(CONTEXT_DEBUGGERS_AVAILABLE),
190189
order: 6
191190
});
192191

src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ import { IModeService } from 'vs/editor/common/services/modeService';
2828
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2929
import Severity from 'vs/base/common/severity';
3030
import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry';
31+
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
3132

3233
const jsonRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
34+
const DEBUGGERS_AVAILABLE_KEY = 'debug.debuggersavailable';
35+
3336
export class AdapterManager implements IAdapterManager {
3437

3538
private debuggers: Debugger[];
@@ -49,12 +52,15 @@ export class AdapterManager implements IAdapterManager {
4952
@IExtensionService private readonly extensionService: IExtensionService,
5053
@IContextKeyService contextKeyService: IContextKeyService,
5154
@IModeService private readonly modeService: IModeService,
52-
@IDialogService private readonly dialogService: IDialogService
55+
@IDialogService private readonly dialogService: IDialogService,
56+
@IStorageService private readonly storageService: IStorageService
5357
) {
5458
this.adapterDescriptorFactories = [];
5559
this.debuggers = [];
5660
this.registerListeners();
61+
const debuggersAvailable = this.storageService.getBoolean(DEBUGGERS_AVAILABLE_KEY, StorageScope.WORKSPACE, false);
5762
this.debuggersAvailable = CONTEXT_DEBUGGERS_AVAILABLE.bindTo(contextKeyService);
63+
this.debuggersAvailable.set(debuggersAvailable);
5864
}
5965

6066
private registerListeners(): void {
@@ -158,6 +164,7 @@ export class AdapterManager implements IAdapterManager {
158164
registerDebugAdapterFactory(debugTypes: string[], debugAdapterLauncher: IDebugAdapterFactory): IDisposable {
159165
debugTypes.forEach(debugType => this.debugAdapterFactories.set(debugType, debugAdapterLauncher));
160166
this.debuggersAvailable.set(this.debugAdapterFactories.size > 0);
167+
this.storageService.store(DEBUGGERS_AVAILABLE_KEY, this.debugAdapterFactories.size > 0, StorageScope.WORKSPACE, StorageTarget.MACHINE);
161168
this._onDidRegisterDebugger.fire();
162169

163170
return {

0 commit comments

Comments
 (0)