提交 de42a6d9 编写于 作者: S Sandeep Somavarapu

Fix #37026

上级 62ff872b
......@@ -244,8 +244,7 @@ export class ViewsViewlet extends PanelViewlet {
// Update headers after and title contributed views after available, since we read from cache in the beginning to know if the viewlet has single view or not. Ref #29609
this.extensionService.onReady().then(() => {
this.areExtensionsReady = true;
this.updateViewHeaders();
this.updateTitleArea();
this.updateHeaders();
});
this.onViewsRegistered(ViewsRegistry.getViews(this.location));
......@@ -408,6 +407,8 @@ export class ViewsViewlet extends PanelViewlet {
const size = (viewState && viewState.size) || viewDescriptor.size || 200;
this.addPanel(view, size, index);
this.viewsViewletPanels.splice(index, 0, view);
this.viewsStates.set(view.id, this.updateViewStateSize(view));
}
return TPromise.join(toCreate.map(view => view.create()))
......@@ -496,6 +497,13 @@ export class ViewsViewlet extends PanelViewlet {
return this.setVisible(this.isVisible());
}
private updateHeaders(): void {
if (this.viewsViewletPanels.length) {
this.updateTitleArea();
this.updateViewHeaders();
}
}
private onContextMenu(event: StandardMouseEvent, view: ViewsViewletPanel): void {
event.stopPropagation();
event.preventDefault();
......@@ -516,11 +524,14 @@ export class ViewsViewlet extends PanelViewlet {
if (!this.showHeaderInTitleWhenSingleView) {
return false;
}
if (this.viewsViewletPanels.length > 1) {
if (this.getViewDescriptorsFromRegistry().length === 0) {
return false;
}
if (this.length > 1) {
return false;
}
// Check in cache so that view do not jump. See #29609
if (ViewLocation.getContributedViewLocation(this.location.id) && !this.areExtensionsReady) {
// Checks in cache so that view do not jump. See #29609
let visibleViewsCount = 0;
this.viewsStates.forEach((viewState, id) => {
if (!viewState.isHidden) {
......@@ -529,7 +540,7 @@ export class ViewsViewlet extends PanelViewlet {
});
return visibleViewsCount === 1;
}
return true;
return super.isSingleView();
}
protected getViewDescriptorsFromRegistry(defaultOrder: boolean = false): IViewDescriptor[] {
......@@ -596,7 +607,11 @@ export class PersistentViewsViewlet extends ViewsViewlet {
@IExtensionService extensionService: IExtensionService
) {
super(id, location, showHeaderInTitleWhenSingleView, telemetryService, storageService, instantiationService, themeService, contextKeyService, contextMenuService, extensionService);
}
create(parent: Builder): TPromise<void> {
this.loadViewsStates();
return super.create(parent);
}
shutdown(): void {
......@@ -604,7 +619,7 @@ export class PersistentViewsViewlet extends ViewsViewlet {
super.shutdown();
}
private saveViewsStates(): void {
protected saveViewsStates(): void {
const viewsStates = {};
const registeredViewDescriptors = this.getViewDescriptorsFromRegistry();
this.viewsStates.forEach((viewState, id) => {
......@@ -623,7 +638,7 @@ export class PersistentViewsViewlet extends ViewsViewlet {
this.storageService.store(this.viewletStateStorageId, JSON.stringify(viewsStates), this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? StorageScope.WORKSPACE : StorageScope.GLOBAL);
}
private loadViewsStates(): void {
protected loadViewsStates(): void {
const viewsStates = JSON.parse(this.storageService.get(this.viewletStateStorageId, this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? StorageScope.WORKSPACE : StorageScope.GLOBAL, '{}'));
Object.keys(viewsStates).forEach(id => this.viewsStates.set(id, <IViewState>viewsStates[id]));
}
......
......@@ -157,7 +157,11 @@ export class ExplorerViewlet extends PersistentViewsViewlet {
}
private updateOpenEditorsVisibility(): void {
this.openEditorsVisibleContextKey.set(this.contextService.getWorkbenchState() === WorkbenchState.EMPTY || this.configurationService.getValue('explorer.openEditors.visible') !== 0);
this.openEditorsVisibleContextKey.set(this.isOpenEditorsVisible());
}
private isOpenEditorsVisible(): boolean {
return this.contextService.getWorkbenchState() === WorkbenchState.EMPTY || this.configurationService.getValue('explorer.openEditors.visible') !== 0;
}
protected createView(viewDescriptor: IViewDescriptor, options: IViewletViewOptions): ViewsViewletPanel {
......@@ -290,4 +294,13 @@ export class ExplorerViewlet extends PersistentViewsViewlet {
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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册