limit "Open Folder" to local/remote only
This commit is contained in:
parent
ac32d7d0a0
commit
770e975ade
2 changed files with 14 additions and 6 deletions
|
@ -12,7 +12,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
|
|||
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL, PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
|
||||
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { MenuRegistry, MenuId, Action2, registerAction2, ILocalizedString } from 'vs/platform/actions/common/actions';
|
||||
import { EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, WorkbenchStateContext, WorkspaceFolderCountContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, OpenFolderWorkspaceSupportContext, WorkbenchStateContext, WorkspaceFolderCountContext } from 'vs/workbench/browser/contextkeys';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
|
@ -60,7 +60,7 @@ export class OpenFolderAction extends Action2 {
|
|||
title: { value: localize('openFolder', "Open Folder..."), original: 'Open Folder...' },
|
||||
category: fileCategory,
|
||||
f1: true,
|
||||
precondition: IsMacNativeContext.toNegated(),
|
||||
precondition: ContextKeyExpr.and(IsMacNativeContext.toNegated(), OpenFolderWorkspaceSupportContext),
|
||||
keybinding: {
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_O)
|
||||
|
@ -86,7 +86,7 @@ export class OpenFileFolderAction extends Action2 {
|
|||
title: OpenFileFolderAction.LABEL,
|
||||
category: fileCategory,
|
||||
f1: true,
|
||||
precondition: IsMacNativeContext,
|
||||
precondition: ContextKeyExpr.and(IsMacNativeContext, OpenFolderWorkspaceSupportContext),
|
||||
keybinding: {
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KEY_O
|
||||
|
@ -314,7 +314,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
|||
title: localize({ key: 'miOpenFolder', comment: ['&& denotes a mnemonic'] }, "Open &&Folder...")
|
||||
},
|
||||
order: 2,
|
||||
when: IsMacNativeContext.toNegated()
|
||||
when: ContextKeyExpr.and(IsMacNativeContext.toNegated(), OpenFolderWorkspaceSupportContext)
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
|
@ -324,7 +324,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
|||
title: localize({ key: 'miOpen', comment: ['&& denotes a mnemonic'] }, "&&Open...")
|
||||
},
|
||||
order: 1,
|
||||
when: IsMacNativeContext
|
||||
when: ContextKeyExpr.and(IsMacNativeContext, OpenFolderWorkspaceSupportContext)
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.MenubarFileMenu, {
|
||||
|
|
|
@ -27,6 +27,7 @@ import { IEditorResolverService } from 'vs/workbench/services/editor/common/edit
|
|||
export const WorkbenchStateContext = new RawContextKey<string>('workbenchState', undefined, { type: 'string', description: localize('workbenchState', "The kind of workspace opened in the window, either 'empty' (no workspace), 'folder' (single folder) or 'workspace' (multi-root workspace)") });
|
||||
export const WorkspaceFolderCountContext = new RawContextKey<number>('workspaceFolderCount', 0, localize('workspaceFolderCount', "The number of root folders in the workspace"));
|
||||
|
||||
export const OpenFolderWorkspaceSupportContext = new RawContextKey<boolean>('openFolderWorkspaceSupport', true, true);
|
||||
export const EnterMultiRootWorkspaceSupportContext = new RawContextKey<boolean>('enterMultiRootWorkspaceSupport', true, true);
|
||||
export const EmptyWorkspaceSupportContext = new RawContextKey<boolean>('emptyWorkspaceSupport', true, true);
|
||||
|
||||
|
@ -63,8 +64,9 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
|||
private workbenchStateContext: IContextKey<string>;
|
||||
private workspaceFolderCountContext: IContextKey<number>;
|
||||
|
||||
private emptyWorkspaceSupportContext: IContextKey<boolean>;
|
||||
private openFolderWorkspaceSupportContext: IContextKey<boolean>;
|
||||
private enterMultiRootWorkspaceSupportContext: IContextKey<boolean>;
|
||||
private emptyWorkspaceSupportContext: IContextKey<boolean>;
|
||||
|
||||
private virtualWorkspaceContext: IContextKey<string>;
|
||||
|
||||
|
@ -139,6 +141,12 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
|||
this.workspaceFolderCountContext = WorkspaceFolderCountContext.bindTo(this.contextKeyService);
|
||||
this.updateWorkspaceFolderCountContextKey();
|
||||
|
||||
// Opening folder support: support for opening a folder workspace
|
||||
// (e.g. "Open Folder...") is limited in web when not connected
|
||||
// to a remote.
|
||||
this.openFolderWorkspaceSupportContext = OpenFolderWorkspaceSupportContext.bindTo(this.contextKeyService);
|
||||
this.openFolderWorkspaceSupportContext.set(isNative || typeof this.environmentService.remoteAuthority === 'string');
|
||||
|
||||
// Empty workspace support: empty workspaces require built-in file system
|
||||
// providers to be available that allow to enter a workspace or open loose
|
||||
// files. This condition is met:
|
||||
|
|
Loading…
Reference in a new issue