From d05ae7a23a19689e047ff44572daed50844d6ea4 Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 2 Apr 2019 12:53:23 +0200 Subject: [PATCH] explorer context keys: some polish --- .../contrib/files/browser/explorerViewlet.ts | 4 +-- .../workbench/contrib/files/common/files.ts | 35 +++++++------------ 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/explorerViewlet.ts b/src/vs/workbench/contrib/files/browser/explorerViewlet.ts index 24eb92de4ae..e605875da76 100644 --- a/src/vs/workbench/contrib/files/browser/explorerViewlet.ts +++ b/src/vs/workbench/contrib/files/browser/explorerViewlet.ts @@ -6,7 +6,7 @@ import 'vs/css!./media/explorerviewlet'; import { localize } from 'vs/nls'; import * as DOM from 'vs/base/browser/dom'; -import { VIEWLET_ID, ExplorerViewletVisibleContext, IFilesConfiguration, OpenEditorsVisibleContext, OpenEditorsVisibleCondition, VIEW_CONTAINER } from 'vs/workbench/contrib/files/common/files'; +import { VIEWLET_ID, ExplorerViewletVisibleContext, IFilesConfiguration, OpenEditorsVisibleContext, VIEW_CONTAINER } from 'vs/workbench/contrib/files/common/files'; import { ViewContainerViewlet, IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet'; import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; import { ExplorerView } from 'vs/workbench/contrib/files/browser/views/explorerView'; @@ -103,7 +103,7 @@ export class ExplorerViewletViewsContribution extends Disposable implements IWor name: OpenEditorsView.NAME, ctorDescriptor: { ctor: OpenEditorsView }, order: 0, - when: OpenEditorsVisibleCondition, + when: OpenEditorsVisibleContext, canToggleVisibility: true, focusCommand: { id: 'workbench.files.action.focusOpenEditorsView', diff --git a/src/vs/workbench/contrib/files/common/files.ts b/src/vs/workbench/contrib/files/common/files.ts index 9eeeafea694..3d8b1c3176e 100644 --- a/src/vs/workbench/contrib/files/common/files.ts +++ b/src/vs/workbench/contrib/files/common/files.ts @@ -67,30 +67,19 @@ export const IExplorerService = createDecorator('explorerServi /** * Context Keys to use with keybindings for the Explorer and Open Editors view */ -const explorerViewletVisibleId = 'explorerViewletVisible'; -const filesExplorerFocusId = 'filesExplorerFocus'; -const openEditorsVisibleId = 'openEditorsVisible'; -const openEditorsFocusId = 'openEditorsFocus'; -const explorerViewletFocusId = 'explorerViewletFocus'; -const explorerResourceIsFolderId = 'explorerResourceIsFolder'; -const explorerResourceReadonly = 'explorerResourceReadonly'; -const explorerResourceIsRootId = 'explorerResourceIsRoot'; -const explorerResourceCutId = 'explorerResourceCut'; - -export const ExplorerViewletVisibleContext = new RawContextKey(explorerViewletVisibleId, true); -export const ExplorerFolderContext = new RawContextKey(explorerResourceIsFolderId, false); -export const ExplorerResourceReadonlyContext = new RawContextKey(explorerResourceReadonly, false); +export const ExplorerViewletVisibleContext = new RawContextKey('explorerViewletVisible', true); +export const ExplorerFolderContext = new RawContextKey('explorerResourceIsFolder', false); +export const ExplorerResourceReadonlyContext = new RawContextKey('explorerResourceReadonly', false); export const ExplorerResourceNotReadonlyContext = ExplorerResourceReadonlyContext.toNegated(); -export const ExplorerRootContext = new RawContextKey(explorerResourceIsRootId, false); -export const ExplorerResourceCut = new RawContextKey(explorerResourceCutId, false); -export const FilesExplorerFocusedContext = new RawContextKey(filesExplorerFocusId, true); -export const OpenEditorsVisibleContext = new RawContextKey(openEditorsVisibleId, false); -export const OpenEditorsFocusedContext = new RawContextKey(openEditorsFocusId, true); -export const ExplorerFocusedContext = new RawContextKey(explorerViewletFocusId, true); - -export const OpenEditorsVisibleCondition = ContextKeyExpr.has(openEditorsVisibleId); -export const FilesExplorerFocusCondition = ContextKeyExpr.and(ContextKeyExpr.has(explorerViewletVisibleId), ContextKeyExpr.has(filesExplorerFocusId), ContextKeyExpr.not(InputFocusedContextKey)); -export const ExplorerFocusCondition = ContextKeyExpr.and(ContextKeyExpr.has(explorerViewletVisibleId), ContextKeyExpr.has(explorerViewletFocusId), ContextKeyExpr.not(InputFocusedContextKey)); +export const ExplorerRootContext = new RawContextKey('explorerResourceIsRoot', false); +export const ExplorerResourceCut = new RawContextKey('explorerResourceCut', false); +export const FilesExplorerFocusedContext = new RawContextKey('filesExplorerFocus', true); +export const OpenEditorsVisibleContext = new RawContextKey('openEditorsVisible', false); +export const OpenEditorsFocusedContext = new RawContextKey('openEditorsFocus', true); +export const ExplorerFocusedContext = new RawContextKey('explorerViewletFocus', true); + +export const FilesExplorerFocusCondition = ContextKeyExpr.and(ExplorerViewletVisibleContext, FilesExplorerFocusedContext, ContextKeyExpr.not(InputFocusedContextKey)); +export const ExplorerFocusCondition = ContextKeyExpr.and(ExplorerViewletVisibleContext, ExplorerFocusedContext, ContextKeyExpr.not(InputFocusedContextKey)); /** * Text file editor id. -- GitLab