提交 4ac4a062 编写于 作者: I isidor

open editors debt: remove openEditors.visible === 0 to hide the view

上级 446cd36a
......@@ -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<boolean>(explorer
export const ExplorerFolderContext = new RawContextKey<boolean>(explorerResourceIsFolderId, false);
export const ExplorerRootContext = new RawContextKey<boolean>(explorerResourceIsRootId, false);
export const FilesExplorerFocusedContext = new RawContextKey<boolean>(filesExplorerFocusId, true);
export const OpenEditorsVisibleContext = new RawContextKey<boolean>(openEditorsVisibleId, false);
export const OpenEditorsFocusedContext = new RawContextKey<boolean>(openEditorsFocusId, true);
export const ExplorerFocusedContext = new RawContextKey<boolean>(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));
......
......@@ -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<boolean>;
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
}
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册