From 4ac4a062e2fa5bc8b7c55eeec9f1d2d31f11ab1a Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 9 Feb 2018 11:40:08 +0100 Subject: [PATCH] open editors debt: remove openEditors.visible === 0 to hide the view --- src/vs/workbench/parts/files/common/files.ts | 3 -- .../files/electron-browser/explorerViewlet.ts | 37 ++----------------- .../electron-browser/views/openEditorsView.ts | 2 +- 3 files changed, 4 insertions(+), 38 deletions(-) diff --git a/src/vs/workbench/parts/files/common/files.ts b/src/vs/workbench/parts/files/common/files.ts index 3147b323330..8924a1f2d1e 100644 --- a/src/vs/workbench/parts/files/common/files.ts +++ b/src/vs/workbench/parts/files/common/files.ts @@ -40,7 +40,6 @@ export interface IExplorerView { */ const explorerViewletVisibleId = 'explorerViewletVisible'; const filesExplorerFocusId = 'filesExplorerFocus'; -const openEditorsVisibleId = 'openEditorsVisible'; const openEditorsFocusId = 'openEditorsFocus'; const explorerViewletFocusId = 'explorerViewletFocus'; const explorerResourceIsFolderId = 'explorerResourceIsFolder'; @@ -50,11 +49,9 @@ export const ExplorerViewletVisibleContext = new RawContextKey(explorer export const ExplorerFolderContext = new RawContextKey(explorerResourceIsFolderId, false); export const ExplorerRootContext = new RawContextKey(explorerResourceIsRootId, 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)); diff --git a/src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts b/src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts index 7dd040a28c2..df259646f71 100644 --- a/src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts +++ b/src/vs/workbench/parts/files/electron-browser/explorerViewlet.ts @@ -11,9 +11,9 @@ import { IActionRunner } from 'vs/base/common/actions'; import { TPromise } from 'vs/base/common/winjs.base'; import * as DOM from 'vs/base/browser/dom'; import { Builder } from 'vs/base/browser/builder'; -import { VIEWLET_ID, ExplorerViewletVisibleContext, IFilesConfiguration, OpenEditorsVisibleContext, OpenEditorsVisibleCondition, IExplorerViewlet } from 'vs/workbench/parts/files/common/files'; +import { VIEWLET_ID, ExplorerViewletVisibleContext, IFilesConfiguration, IExplorerViewlet } from 'vs/workbench/parts/files/common/files'; import { PersistentViewsViewlet, IViewletViewOptions, ViewsViewletPanel } from 'vs/workbench/browser/parts/views/viewsViewlet'; -import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ActionRunner, FileViewletState } from 'vs/workbench/parts/files/electron-browser/views/explorerViewer'; import { ExplorerView, IExplorerViewOptions } from 'vs/workbench/parts/files/electron-browser/views/explorerView'; import { EmptyView } from 'vs/workbench/parts/files/electron-browser/views/emptyView'; @@ -38,23 +38,16 @@ import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; export class ExplorerViewletViewsContribution extends Disposable implements IWorkbenchContribution { - private openEditorsVisibleContextKey: IContextKey; - constructor( @IWorkspaceContextService private workspaceContextService: IWorkspaceContextService, - @IConfigurationService private configurationService: IConfigurationService, @IContextKeyService contextKeyService: IContextKeyService ) { super(); this.registerViews(); - this.openEditorsVisibleContextKey = OpenEditorsVisibleContext.bindTo(contextKeyService); - this.updateOpenEditorsVisibility(); - this._register(workspaceContextService.onDidChangeWorkbenchState(() => this.registerViews())); this._register(workspaceContextService.onDidChangeWorkspaceFolders(() => this.registerViews())); - this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e))); } private registerViews(): void { @@ -104,7 +97,6 @@ export class ExplorerViewletViewsContribution extends Disposable implements IWor location: ViewLocation.Explorer, ctor: OpenEditorsView, order: 0, - when: OpenEditorsVisibleCondition, canToggleVisibility: true }; } @@ -130,16 +122,6 @@ export class ExplorerViewletViewsContribution extends Disposable implements IWor canToggleVisibility: false }; } - - private onConfigurationUpdated(e: IConfigurationChangeEvent): void { - if (e.affectsConfiguration('explorer.openEditors.visible')) { - this.updateOpenEditorsVisibility(); - } - } - - private updateOpenEditorsVisibility(): void { - this.openEditorsVisibleContextKey.set(this.workspaceContextService.getWorkbenchState() === WorkbenchState.EMPTY || this.configurationService.getValue('explorer.openEditors.visible') !== 0); - } } export class ExplorerViewlet extends PersistentViewsViewlet implements IExplorerViewlet { @@ -177,10 +159,6 @@ export class ExplorerViewlet extends PersistentViewsViewlet implements IExplorer DOM.addClass(el, 'explorer-viewlet'); } - private isOpenEditorsVisible(): boolean { - return this.contextService.getWorkbenchState() === WorkbenchState.EMPTY || this.configurationService.getValue('explorer.openEditors.visible') !== 0; - } - protected createView(viewDescriptor: IViewDescriptor, options: IViewletViewOptions): ViewsViewletPanel { if (viewDescriptor.id === ExplorerView.ID) { // Create a delegating editor service for the explorer to be able to delay the refresh in the opened @@ -253,13 +231,4 @@ export class ExplorerViewlet extends PersistentViewsViewlet implements IExplorer public getViewletState(): FileViewletState { return this.viewletState; } - - protected loadViewsStates(): void { - super.loadViewsStates(); - - // Remove the open editors view state if it is removed globally - if (!this.isOpenEditorsVisible()) { - this.viewsStates.delete(OpenEditorsView.ID); - } - } -} \ No newline at end of file +} diff --git a/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts b/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts index 93fd707fffc..b61784de96e 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts @@ -396,7 +396,7 @@ export class OpenEditorsView extends ViewsViewletPanel { } private computeMinExpandedBodySize(visibleOpenEditors = OpenEditorsView.DEFAULT_VISIBLE_OPEN_EDITORS): number { - const itemsToShow = Math.min(Math.max(visibleOpenEditors, 1), this.elementCount); + const itemsToShow = Math.min(Math.max(visibleOpenEditors, 0), this.elementCount); return itemsToShow * OpenEditorsDelegate.ITEM_HEIGHT; } -- GitLab