Listen on explorer view collapse / expand to expand the fixed open editors view

fixes #6666
This commit is contained in:
isidor 2016-06-15 16:59:25 +02:00
parent f0c511b372
commit 11e5950dda
3 changed files with 30 additions and 5 deletions

View file

@ -6,7 +6,7 @@
'use strict';
import 'vs/css!./media/explorerviewlet';
import {IDisposable} from 'vs/base/common/lifecycle';
import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import {IAction} from 'vs/base/common/actions';
import {TPromise} from 'vs/base/common/winjs.base';
import {Dimension, Builder} from 'vs/base/browser/builder';
@ -47,6 +47,7 @@ export class ExplorerViewlet extends Viewlet {
private viewletSettings: any;
private viewletState: FileViewletState;
private dimension: Dimension;
private toDispose: IDisposable[];
private viewletVisibleContextKey: IKeybindingContextKey<boolean>;
@ -67,6 +68,7 @@ export class ExplorerViewlet extends Viewlet {
this.viewletSettings = this.getMemento(storageService, Scope.WORKSPACE);
this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationUpdated(e.config));
this.toDispose = [];
}
public create(parent: Builder): TPromise<void> {
@ -175,6 +177,18 @@ export class ExplorerViewlet extends Viewlet {
const headerSize = this.openEditorsVisible ? undefined : 0; // If open editors are not visible set header size explicitly to 0, otherwise let it be computed by super class.
this.explorerView = explorerView = explorerInstantiator.createInstance(ExplorerView, this.viewletState, this.getActionRunner(), this.viewletSettings, headerSize);
// Listen on explorer view collapse / expand to grow / shrink the fixed open editors view #6666
this.toDispose.push(this.explorerView.addListener2('collapse', () => {
if (this.openEditorsView) {
this.openEditorsView.updateBodySize(Number.MAX_VALUE);
}
}));
this.toDispose.push(this.explorerView.addListener2('expand', () => {
if (this.openEditorsView) {
this.openEditorsView.updateBodySize();
}
}));
}
// No workspace
@ -288,6 +302,7 @@ export class ExplorerViewlet extends Viewlet {
}
public dispose(): void {
this.toDispose = dispose(this.toDispose);
if (this.splitView) {
this.splitView.dispose();
this.splitView = null;

View file

@ -104,6 +104,16 @@ export class ExplorerView extends CollapsibleViewletView {
super.renderHeader(container);
}
public collapse(): void {
super.collapse();
this.emit('collapse');
}
public expand(): void {
super.expand();
this.emit('expand');
}
public renderBody(container: HTMLElement): void {
this.treeContainer = super.renderViewTree(container);
DOM.addClass(this.treeContainer, 'explorer-folders-view');

View file

@ -166,7 +166,7 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
private structuralTreeUpdate(): void {
// View size
this.expandedBodySize = this.getExpandedBodySize(this.model);
this.updateBodySize();
// Show groups only if there is more than 1 group
const treeInput = this.model.groups.length === 1 ? this.model.groups[0] : this.model;
// TODO@Isidor temporary workaround due to a partial tree refresh issue
@ -212,7 +212,7 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
}
// Adjust expanded body size
this.expandedBodySize = this.getExpandedBodySize(this.model);
this.updateBodySize();
}
private updateDirtyIndicator(): void {
@ -226,8 +226,8 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
}
}
private getExpandedBodySize(model: IEditorStacksModel): number {
return OpenEditorsView.computeExpandedBodySize(model, this.visibleOpenEditors, this.dynamicHeight);
public updateBodySize(newSize?: number): void {
this.expandedBodySize = newSize ? newSize : OpenEditorsView.computeExpandedBodySize(this.model, this.visibleOpenEditors, this.dynamicHeight);
}
private static computeExpandedBodySize(model: IEditorStacksModel, visibleOpenEditors = OpenEditorsView.DEFAULT_VISIBLE_OPEN_EDITORS, dynamicHeight = OpenEditorsView.DEFAULT_DYNAMIC_HEIGHT): number {