mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-04 19:35:46 +01:00
contextkey - add web to statically defined ones
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { isFalsyOrWhitespace } from 'vs/base/common/strings';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { isMacintosh, isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { isMacintosh, isLinux, isWindows, isWeb } from 'vs/base/common/platform';
|
||||
|
||||
const STATIC_VALUES = new Map<string, boolean>();
|
||||
STATIC_VALUES.set('false', false);
|
||||
@@ -14,6 +14,8 @@ STATIC_VALUES.set('true', true);
|
||||
STATIC_VALUES.set('isMac', isMacintosh);
|
||||
STATIC_VALUES.set('isLinux', isLinux);
|
||||
STATIC_VALUES.set('isWindows', isWindows);
|
||||
STATIC_VALUES.set('isWeb', isWeb);
|
||||
STATIC_VALUES.set('isMacNative', isMacintosh && !isWeb);
|
||||
|
||||
export const enum ContextKeyExprType {
|
||||
False = 0,
|
||||
|
||||
@@ -4,8 +4,16 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { isMacintosh, isLinux, isWindows, isWeb } from 'vs/base/common/platform';
|
||||
|
||||
export const IsMacContext = new RawContextKey<boolean>('isMac', isMacintosh);
|
||||
export const IsLinuxContext = new RawContextKey<boolean>('isLinux', isLinux);
|
||||
export const IsWindowsContext = new RawContextKey<boolean>('isWindows', isWindows);
|
||||
|
||||
export const IsWebContext = new RawContextKey<boolean>('isWeb', isWeb);
|
||||
export const IsMacNativeContext = new RawContextKey<boolean>('isMacNative', isMacintosh && !isWeb);
|
||||
|
||||
export const IsDevelopmentContext = new RawContextKey<boolean>('isDevelopment', false);
|
||||
|
||||
export const InputFocusedContextKey = 'inputFocus';
|
||||
export const InputFocusedContext = new RawContextKey<boolean>(InputFocusedContextKey, false);
|
||||
|
||||
export const FalseContext = new RawContextKey<boolean>('__false', false);
|
||||
|
||||
@@ -18,7 +18,7 @@ import { KeyMod, KeyCode, KeyChord } from 'vs/base/common/keyCodes';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { getMenuBarVisibility } from 'vs/platform/windows/common/windows';
|
||||
import { isWindows, isLinux, isWeb } from 'vs/base/common/platform';
|
||||
import { IsMacNativeContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IsMacNativeContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { InEditorZenModeContext, IsCenteredLayoutContext, EditorAreaVisibleContext } from 'vs/workbench/common/editor';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
@@ -12,7 +12,8 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { IsFullscreenContext, IsDevelopmentContext, IsMacNativeContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IsFullscreenContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IsMacNativeContext, IsDevelopmentContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IQuickInputButton, IQuickInputService, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { InputFocusedContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { IWindowsConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { ActiveEditorContext, EditorsVisibleContext, TextCompareEditorVisibleContext, TextCompareEditorActiveContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, TEXT_DIFF_EDITOR_ID, SplitEditorsVertically, InEditorZenModeContext, IsCenteredLayoutContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorIsReadonlyContext, EditorAreaVisibleContext, DirtyWorkingCopiesContext } from 'vs/workbench/common/editor';
|
||||
import { trackFocus, addDisposableListener, EventType } from 'vs/base/browser/dom';
|
||||
import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
@@ -18,27 +17,15 @@ import { WorkbenchState, IWorkspaceContextService } from 'vs/platform/workspace/
|
||||
import { SideBarVisibleContext } from 'vs/workbench/common/viewlet';
|
||||
import { IWorkbenchLayoutService, Parts, positionToString } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { isMacintosh, isLinux, isWindows, isWeb } from 'vs/base/common/platform';
|
||||
import { PanelPositionContext } from 'vs/workbench/common/panel';
|
||||
import { getRemoteName } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
|
||||
export const IsMacContext = new RawContextKey<boolean>('isMac', isMacintosh);
|
||||
export const IsLinuxContext = new RawContextKey<boolean>('isLinux', isLinux);
|
||||
export const IsWindowsContext = new RawContextKey<boolean>('isWindows', isWindows);
|
||||
|
||||
export const IsWebContext = new RawContextKey<boolean>('isWeb', isWeb);
|
||||
export const IsMacNativeContext = new RawContextKey<boolean>('isMacNative', isMacintosh && !isWeb);
|
||||
|
||||
export const Deprecated_RemoteAuthorityContext = new RawContextKey<string>('remoteAuthority', '');
|
||||
|
||||
export const RemoteNameContext = new RawContextKey<string>('remoteName', '');
|
||||
export const RemoteConnectionState = new RawContextKey<'' | 'initializing' | 'disconnected' | 'connected'>('remoteConnectionState', '');
|
||||
|
||||
export const HasMacNativeTabsContext = new RawContextKey<boolean>('hasMacNativeTabs', false);
|
||||
|
||||
export const IsDevelopmentContext = new RawContextKey<boolean>('isDevelopment', false);
|
||||
|
||||
export const WorkbenchStateContext = new RawContextKey<string>('workbenchState', undefined);
|
||||
|
||||
export const WorkspaceFolderCountContext = new RawContextKey<number>('workspaceFolderCount', 0);
|
||||
@@ -98,10 +85,6 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
||||
|
||||
RemoteNameContext.bindTo(this.contextKeyService).set(getRemoteName(this.environmentService.configuration.remoteAuthority) || '');
|
||||
|
||||
// macOS Native Tabs
|
||||
const windowConfig = this.configurationService.getValue<IWindowsConfiguration>();
|
||||
HasMacNativeTabsContext.bindTo(this.contextKeyService).set(windowConfig?.window?.nativeTabs);
|
||||
|
||||
// Development
|
||||
IsDevelopmentContext.bindTo(this.contextKeyService).set(!this.environmentService.isBuilt || this.environmentService.isExtensionDevelopment);
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ import { KeyChord, KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { WorkbenchStateContext, RemoteNameContext, IsWebContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { WorkbenchStateContext, RemoteNameContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { AddRootFolderAction, OpenFolderAction, OpenFileFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ import { AutoSaveAfterShortDelayContext } from 'vs/workbench/services/filesConfi
|
||||
import { ResourceContextKey } from 'vs/workbench/common/resources';
|
||||
import { WorkbenchListDoubleSelection } from 'vs/platform/list/browser/listService';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { WorkspaceFolderCountContext, IsWebContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { WorkspaceFolderCountContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { OpenFileFolderAction, OpenFileAction, OpenFolderAction, OpenWorkspaceAction } from 'vs/workbench/browser/actions/workspaceActions';
|
||||
import { ActiveEditorIsReadonlyContext, DirtyWorkingCopiesContext, ActiveEditorContext } from 'vs/workbench/common/editor';
|
||||
|
||||
@@ -20,7 +20,8 @@ import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { REMOTE_HOST_SCHEME } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IsMacNativeContext, RemoteNameContext, WorkbenchStateContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { RemoteNameContext, WorkbenchStateContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IsMacNativeContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { EditorDescriptor, Extensions as EditorExtensions, IEditorRegistry } from 'vs/workbench/browser/editor';
|
||||
import { Extensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||
|
||||
@@ -22,10 +22,9 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
||||
import { ReleaseNotesManager } from './releaseNotesEditor';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { RawContextKey, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { RawContextKey, IContextKey, IContextKeyService, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { FalseContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { ShowCurrentReleaseNotesActionId, CheckForVSCodeUpdateActionId } from 'vs/workbench/contrib/update/common/update';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
@@ -417,7 +416,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
|
||||
command: {
|
||||
id: 'update.checking',
|
||||
title: nls.localize('checkingForUpdates', "Checking for Updates..."),
|
||||
precondition: FalseContext
|
||||
precondition: ContextKeyExpr.false()
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.CheckingForUpdates)
|
||||
});
|
||||
@@ -438,7 +437,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
|
||||
command: {
|
||||
id: 'update.downloading',
|
||||
title: nls.localize('DownloadingUpdate', "Downloading Update..."),
|
||||
precondition: FalseContext
|
||||
precondition: ContextKeyExpr.false()
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Downloading)
|
||||
});
|
||||
@@ -459,7 +458,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
|
||||
command: {
|
||||
id: 'update.updating',
|
||||
title: nls.localize('installingUpdate', "Installing Update..."),
|
||||
precondition: FalseContext
|
||||
precondition: ContextKeyExpr.false()
|
||||
},
|
||||
when: CONTEXT_UPDATE_STATE.isEqualTo(StateType.Updating)
|
||||
});
|
||||
|
||||
@@ -17,7 +17,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IsMacContext, HasMacNativeTabsContext, IsDevelopmentContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { IsDevelopmentContext, IsMacContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { NoEditorsVisibleContext, SingleEditorGroupsContext } from 'vs/workbench/common/editor';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
@@ -82,7 +82,7 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||
command,
|
||||
when: HasMacNativeTabsContext
|
||||
when: ContextKeyExpr.equals('config.window.nativeTabs', 'true')
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user