mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 11:08:31 -05:00
Merge from vscode 6268feb42ba4f2e2fa15484e88c9af60d254998c (#6530)
This commit is contained in:
@@ -27,7 +27,7 @@ import { IWindowService, MenuBarVisibility, getTitleBarStyle } from 'vs/platform
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { Sizing, Direction, Grid, SerializableGrid, ISerializableView, ISerializedGrid } from 'vs/base/browser/ui/grid/grid';
|
||||
import { Sizing, Direction, Grid, SerializableGrid, ISerializableView, ISerializedGrid, GridBranchNode, GridLeafNode, isGridBranchNode } from 'vs/base/browser/ui/grid/grid';
|
||||
import { WorkbenchLegacyLayout } from 'vs/workbench/browser/legacyLayout';
|
||||
import { IDimension } from 'vs/platform/layout/browser/layoutService';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
@@ -749,21 +749,25 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
try {
|
||||
workbenchGrid = SerializableGrid.deserialize(parsedGrid, { fromJSON }, { proportionalLayout: false });
|
||||
|
||||
// Set some layout state
|
||||
this.state.sideBar.position = Position.LEFT;
|
||||
for (let view of workbenchGrid.getNeighborViews(this.sideBarPartView, Direction.Right)) {
|
||||
if (view === this.activityBarPartView) {
|
||||
this.state.sideBar.position = Position.RIGHT;
|
||||
}
|
||||
const root = workbenchGrid.getViews();
|
||||
const titleBarSection = root.children[0];
|
||||
|
||||
if (isGridBranchNode(titleBarSection) || titleBarSection.view !== this.titleBarPartView) {
|
||||
throw new Error('Bad grid');
|
||||
}
|
||||
|
||||
this.state.panel.position = Position.BOTTOM;
|
||||
for (let view of workbenchGrid.getNeighborViews(this.panelPartView, Direction.Left)) {
|
||||
if (view === this.editorPartView) {
|
||||
this.state.panel.position = Position.RIGHT;
|
||||
}
|
||||
const middleSection = root.children[1] as GridBranchNode<ISerializableView>;
|
||||
const sideBarPosition = (middleSection.children[0] as GridLeafNode<ISerializableView>).view === this.activityBarPartView ? Position.LEFT : Position.RIGHT;
|
||||
if (sideBarPosition !== this.state.sideBar.position) {
|
||||
throw new Error('Bad Grid');
|
||||
}
|
||||
|
||||
const panelPosition = isGridBranchNode(middleSection.children[2]) || isGridBranchNode(middleSection.children[0]) ? Position.BOTTOM : Position.RIGHT;
|
||||
if (panelPosition !== this.state.panel.position) {
|
||||
throw new Error('Bad Grid');
|
||||
}
|
||||
} catch (err) {
|
||||
workbenchGrid = undefined;
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
@@ -783,6 +787,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
this.setPanelHidden(!visible, true);
|
||||
}));
|
||||
|
||||
this._register((this.editorPartView as PanelPart).onDidVisibilityChange((visible) => {
|
||||
this.setEditorHidden(!visible, true);
|
||||
}));
|
||||
|
||||
this._register(this.lifecycleService.onBeforeShutdown(beforeShutdownEvent => {
|
||||
beforeShutdownEvent.veto(new Promise((resolve) => {
|
||||
const grid = this.workbenchGrid as SerializableGrid<ISerializableView>;
|
||||
@@ -849,8 +857,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
statusBarInGrid = true;
|
||||
}
|
||||
|
||||
if (!titlebarInGrid && getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
|
||||
if (!titlebarInGrid) {
|
||||
this.workbenchGrid.addView(this.titleBarPartView, Sizing.Split, this.editorPartView, Direction.Up);
|
||||
|
||||
titlebarInGrid = true;
|
||||
}
|
||||
|
||||
@@ -1157,6 +1166,11 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
} else {
|
||||
size.width = this.state.panel.sizeBeforeMaximize;
|
||||
}
|
||||
|
||||
// Unhide the editor if needed
|
||||
if (this.state.editor.hidden) {
|
||||
this.setEditorHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
this.workbenchGrid.resizeView(this.panelPartView, size);
|
||||
@@ -1166,6 +1180,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
}
|
||||
|
||||
isPanelMaximized(): boolean {
|
||||
if (!this.workbenchGrid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.workbenchGrid instanceof Grid) {
|
||||
try {
|
||||
// The panel is maximum when the editor is minimum
|
||||
|
||||
@@ -111,6 +111,9 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
|
||||
private _onDidSizeConstraintsChange = this._register(new Relay<{ width: number; height: number; } | undefined>());
|
||||
get onDidSizeConstraintsChange(): Event<{ width: number; height: number; } | undefined> { return Event.any(this.onDidSetGridWidget.event, this._onDidSizeConstraintsChange.event); }
|
||||
|
||||
private _onDidVisibilityChange = this._register(new Emitter<boolean>());
|
||||
readonly onDidVisibilityChange: Event<boolean> = this._onDidVisibilityChange.event;
|
||||
|
||||
//#endregion
|
||||
|
||||
private readonly workspaceMemento: MementoObject;
|
||||
@@ -743,6 +746,8 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
|
||||
get minimumHeight(): number { return this.centeredLayoutWidget.minimumHeight; }
|
||||
get maximumHeight(): number { return this.centeredLayoutWidget.maximumHeight; }
|
||||
|
||||
readonly snap = true;
|
||||
|
||||
get onDidChange(): Event<IViewSize | undefined> { return this.centeredLayoutWidget.onDidChange; }
|
||||
readonly priority: LayoutPriority = LayoutPriority.High;
|
||||
|
||||
@@ -986,6 +991,10 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
|
||||
|
||||
//#endregion
|
||||
|
||||
setVisible(visible: boolean): void {
|
||||
this._onDidVisibilityChange.fire(visible);
|
||||
}
|
||||
|
||||
toJSON(): object {
|
||||
return {
|
||||
type: Parts.EDITOR_PART
|
||||
|
||||
@@ -13,7 +13,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
|
||||
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
|
||||
import { ContextAwareMenuEntryActionViewItem, createAndFillInActionBarActions, createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IViewsService, ITreeView, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ITreeViewDescriptor, IViewsRegistry, ViewContainer, ITreeItemLabel, Extensions } from 'vs/workbench/common/views';
|
||||
import { ITreeView, ITreeItem, TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ITreeViewDescriptor, IViewsRegistry, ViewContainer, ITreeItemLabel, Extensions } from 'vs/workbench/common/views';
|
||||
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
@@ -56,9 +56,9 @@ export class CustomTreeViewPanel extends ViewletPanel {
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IViewsService viewsService: IViewsService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
) {
|
||||
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: options.title }, keybindingService, contextMenuService, configurationService);
|
||||
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: options.title }, keybindingService, contextMenuService, configurationService, contextKeyService);
|
||||
const { treeView } = (<ITreeViewDescriptor>Registry.as<IViewsRegistry>(Extensions.ViewsRegistry).getView(options.id));
|
||||
this.treeView = treeView;
|
||||
this._register(this.treeView.onDidChangeActions(() => this.updateActions(), this));
|
||||
@@ -405,7 +405,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
|
||||
}));
|
||||
this.tree.setInput(this.root).then(() => this.updateContentAreas());
|
||||
|
||||
const customTreeNavigator = new TreeResourceNavigator2(this.tree);
|
||||
const customTreeNavigator = new TreeResourceNavigator2(this.tree, { openOnFocus: false, openOnSelection: false });
|
||||
this._register(customTreeNavigator);
|
||||
this._register(customTreeNavigator.onDidOpenResource(e => {
|
||||
if (!e.browserEvent) {
|
||||
|
||||
@@ -113,7 +113,8 @@
|
||||
flex: 1;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
flex-wrap: nowrap
|
||||
flex-wrap: nowrap;
|
||||
padding-left: 3px;
|
||||
}
|
||||
|
||||
.customview-tree .monaco-list .monaco-list-row .custom-view-tree-node-item .custom-view-tree-node-item-resourceLabel {
|
||||
@@ -156,4 +157,4 @@
|
||||
background-size: 16px;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ import { PanelView, IPanelViewOptions, IPanelOptions, Panel } from 'vs/base/brow
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
|
||||
import { IView } from 'vs/workbench/common/views';
|
||||
import { IView, FocusedViewContext } from 'vs/workbench/common/views';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
export interface IPanelColors extends IColorMapping {
|
||||
dropBackground?: ColorIdentifier;
|
||||
@@ -58,6 +59,8 @@ export abstract class ViewletPanel extends Panel implements IView {
|
||||
protected _onDidChangeTitleArea = this._register(new Emitter<void>());
|
||||
readonly onDidChangeTitleArea: Event<void> = this._onDidChangeTitleArea.event;
|
||||
|
||||
private focusedViewContextKey: IContextKey<string>;
|
||||
|
||||
private _isVisible: boolean = false;
|
||||
readonly id: string;
|
||||
readonly title: string;
|
||||
@@ -71,13 +74,15 @@ export abstract class ViewletPanel extends Panel implements IView {
|
||||
options: IViewletPanelOptions,
|
||||
@IKeybindingService protected keybindingService: IKeybindingService,
|
||||
@IContextMenuService protected contextMenuService: IContextMenuService,
|
||||
@IConfigurationService protected readonly configurationService: IConfigurationService
|
||||
@IConfigurationService protected readonly configurationService: IConfigurationService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService
|
||||
) {
|
||||
super(options);
|
||||
|
||||
this.id = options.id;
|
||||
this.title = options.title;
|
||||
this.actionRunner = options.actionRunner;
|
||||
this.focusedViewContextKey = FocusedViewContext.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
setVisible(visible: boolean): void {
|
||||
@@ -112,8 +117,14 @@ export abstract class ViewletPanel extends Panel implements IView {
|
||||
|
||||
const focusTracker = trackFocus(this.element);
|
||||
this._register(focusTracker);
|
||||
this._register(focusTracker.onDidFocus(() => this._onDidFocus.fire()));
|
||||
this._register(focusTracker.onDidBlur(() => this._onDidBlur.fire()));
|
||||
this._register(focusTracker.onDidFocus(() => {
|
||||
this.focusedViewContextKey.set(this.id);
|
||||
this._onDidFocus.fire();
|
||||
}));
|
||||
this._register(focusTracker.onDidBlur(() => {
|
||||
this.focusedViewContextKey.reset();
|
||||
this._onDidBlur.fire();
|
||||
}));
|
||||
}
|
||||
|
||||
protected renderHeader(container: HTMLElement): void {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
|
||||
import { IContextKeyService, IContextKeyChangeEvent, IReadableSet, IContextKey, RawContextKey, ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { sortedDiff, firstIndex, move, isNonEmptyArray } from 'vs/base/common/arrays';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { isUndefinedOrNull, isUndefined } from 'vs/base/common/types';
|
||||
import { MenuId, MenuRegistry, ICommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { localize } from 'vs/nls';
|
||||
@@ -205,9 +205,9 @@ class ViewDescriptorCollection extends Disposable implements IViewDescriptorColl
|
||||
}
|
||||
|
||||
export interface IViewState {
|
||||
visibleGlobal: boolean;
|
||||
visibleWorkspace: boolean;
|
||||
collapsed: boolean;
|
||||
visibleGlobal: boolean | undefined;
|
||||
visibleWorkspace: boolean | undefined;
|
||||
collapsed: boolean | undefined;
|
||||
order?: number;
|
||||
size?: number;
|
||||
}
|
||||
@@ -287,7 +287,7 @@ export class ContributableViewsModel extends Disposable {
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
this._onDidAdd.fire([{ index: visibleIndex, viewDescriptor, size: state.size, collapsed: state.collapsed }]);
|
||||
this._onDidAdd.fire([{ index: visibleIndex, viewDescriptor, size: state.size, collapsed: !!state.collapsed }]);
|
||||
} else {
|
||||
this._onDidRemove.fire([{ index: visibleIndex, viewDescriptor }]);
|
||||
}
|
||||
@@ -300,7 +300,7 @@ export class ContributableViewsModel extends Disposable {
|
||||
throw new Error(`Unknown view ${id}`);
|
||||
}
|
||||
|
||||
return state.collapsed;
|
||||
return !!state.collapsed;
|
||||
}
|
||||
|
||||
setCollapsed(id: string, collapsed: boolean): void {
|
||||
@@ -354,7 +354,7 @@ export class ContributableViewsModel extends Disposable {
|
||||
if (!viewState) {
|
||||
throw new Error(`Unknown view ${viewDescriptor.id}`);
|
||||
}
|
||||
return viewDescriptor.workspace ? viewState.visibleWorkspace : viewState.visibleGlobal;
|
||||
return viewDescriptor.workspace ? !!viewState.visibleWorkspace : !!viewState.visibleGlobal;
|
||||
}
|
||||
|
||||
private find(id: string): { index: number, visibleIndex: number, viewDescriptor: IViewDescriptor, state: IViewState } {
|
||||
@@ -444,7 +444,7 @@ export class ContributableViewsModel extends Disposable {
|
||||
const state = this.viewStates.get(viewDescriptor.id)!;
|
||||
|
||||
if (this.isViewDescriptorVisible(viewDescriptor)) {
|
||||
toAdd.push({ index: startIndex++, viewDescriptor, size: state.size, collapsed: state.collapsed });
|
||||
toAdd.push({ index: startIndex++, viewDescriptor, size: state.size, collapsed: !!state.collapsed });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,10 +461,23 @@ export class ContributableViewsModel extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
interface IStoredWorkspaceViewState {
|
||||
collapsed: boolean;
|
||||
isHidden: boolean;
|
||||
size?: number;
|
||||
order?: number;
|
||||
}
|
||||
|
||||
interface IStoredGlobalViewState {
|
||||
id: string;
|
||||
isHidden: boolean;
|
||||
order?: number;
|
||||
}
|
||||
|
||||
export class PersistentContributableViewsModel extends ContributableViewsModel {
|
||||
|
||||
private viewletStateStorageId: string;
|
||||
private readonly hiddenViewsStorageId: string;
|
||||
private readonly workspaceViewsStateStorageId: string;
|
||||
private readonly globalViewsStateStorageId: string;
|
||||
|
||||
private storageService: IStorageService;
|
||||
|
||||
@@ -474,13 +487,13 @@ export class PersistentContributableViewsModel extends ContributableViewsModel {
|
||||
@IViewsService viewsService: IViewsService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
) {
|
||||
const hiddenViewsStorageId = `${viewletStateStorageId}.hidden`;
|
||||
const viewStates = PersistentContributableViewsModel.loadViewsStates(viewletStateStorageId, hiddenViewsStorageId, storageService);
|
||||
const globalViewsStateStorageId = `${viewletStateStorageId}.hidden`;
|
||||
const viewStates = PersistentContributableViewsModel.loadViewsStates(viewletStateStorageId, globalViewsStateStorageId, storageService);
|
||||
|
||||
super(container, viewsService, viewStates);
|
||||
|
||||
this.viewletStateStorageId = viewletStateStorageId;
|
||||
this.hiddenViewsStorageId = hiddenViewsStorageId;
|
||||
this.workspaceViewsStateStorageId = viewletStateStorageId;
|
||||
this.globalViewsStateStorageId = globalViewsStateStorageId;
|
||||
this.storageService = storageService;
|
||||
|
||||
this._register(Event.any(
|
||||
@@ -492,84 +505,106 @@ export class PersistentContributableViewsModel extends ContributableViewsModel {
|
||||
}
|
||||
|
||||
private saveViewsStates(viewDescriptors: IViewDescriptor[]): void {
|
||||
const storedViewsStates: { [id: string]: { collapsed: boolean, size?: number, order?: number } } = {};
|
||||
this.saveWorkspaceViewsStates();
|
||||
this.saveGlobalViewsStates();
|
||||
}
|
||||
|
||||
private saveWorkspaceViewsStates(): void {
|
||||
const storedViewsStates: { [id: string]: IStoredWorkspaceViewState } = {};
|
||||
|
||||
let hasState = false;
|
||||
for (const viewDescriptor of this.viewDescriptors) {
|
||||
const viewState = this.viewStates.get(viewDescriptor.id);
|
||||
if (viewState) {
|
||||
storedViewsStates[viewDescriptor.id] = { collapsed: viewState.collapsed, size: viewState.size, order: viewState.order };
|
||||
storedViewsStates[viewDescriptor.id] = {
|
||||
collapsed: !!viewState.collapsed,
|
||||
isHidden: !viewState.visibleWorkspace,
|
||||
size: viewState.size,
|
||||
order: viewDescriptor.workspace && viewState ? viewState.order : undefined
|
||||
};
|
||||
hasState = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasState) {
|
||||
this.storageService.store(this.viewletStateStorageId, JSON.stringify(storedViewsStates), StorageScope.WORKSPACE);
|
||||
this.storageService.store(this.workspaceViewsStateStorageId, JSON.stringify(storedViewsStates), StorageScope.WORKSPACE);
|
||||
} else {
|
||||
this.storageService.remove(this.viewletStateStorageId, StorageScope.WORKSPACE);
|
||||
}
|
||||
|
||||
this.saveVisibilityStates(viewDescriptors);
|
||||
}
|
||||
|
||||
private saveVisibilityStates(viewDescriptors: IViewDescriptor[]): void {
|
||||
const globalViews: IViewDescriptor[] = viewDescriptors.filter(v => !v.workspace);
|
||||
const workspaceViews: IViewDescriptor[] = viewDescriptors.filter(v => v.workspace);
|
||||
if (globalViews.length) {
|
||||
this.saveVisibilityStatesInScope(globalViews, StorageScope.GLOBAL);
|
||||
}
|
||||
if (workspaceViews.length) {
|
||||
this.saveVisibilityStatesInScope(workspaceViews, StorageScope.WORKSPACE);
|
||||
this.storageService.remove(this.workspaceViewsStateStorageId, StorageScope.WORKSPACE);
|
||||
}
|
||||
}
|
||||
|
||||
private saveVisibilityStatesInScope(viewDescriptors: IViewDescriptor[], scope: StorageScope): void {
|
||||
const storedViewsVisibilityStates = PersistentContributableViewsModel.loadViewsVisibilityState(this.hiddenViewsStorageId, this.storageService, scope);
|
||||
for (const viewDescriptor of viewDescriptors) {
|
||||
if (viewDescriptor.canToggleVisibility) {
|
||||
const viewState = this.viewStates.get(viewDescriptor.id);
|
||||
storedViewsVisibilityStates.set(viewDescriptor.id, { id: viewDescriptor.id, isHidden: viewState ? (scope === StorageScope.GLOBAL ? !viewState.visibleGlobal : !viewState.visibleWorkspace) : false });
|
||||
}
|
||||
private saveGlobalViewsStates(): void {
|
||||
const storedViewsVisibilityStates = PersistentContributableViewsModel.loadGlobalViewsState(this.globalViewsStateStorageId, this.storageService, StorageScope.GLOBAL);
|
||||
for (const viewDescriptor of this.viewDescriptors) {
|
||||
const viewState = this.viewStates.get(viewDescriptor.id);
|
||||
storedViewsVisibilityStates.set(viewDescriptor.id, {
|
||||
id: viewDescriptor.id,
|
||||
isHidden: viewState && viewDescriptor.canToggleVisibility ? !viewState.visibleGlobal : false,
|
||||
order: !viewDescriptor.workspace && viewState ? viewState.order : undefined
|
||||
});
|
||||
}
|
||||
this.storageService.store(this.hiddenViewsStorageId, JSON.stringify(values(storedViewsVisibilityStates)), scope);
|
||||
this.storageService.store(this.globalViewsStateStorageId, JSON.stringify(values(storedViewsVisibilityStates)), StorageScope.GLOBAL);
|
||||
}
|
||||
|
||||
private static loadViewsStates(viewletStateStorageId: string, hiddenViewsStorageId: string, storageService: IStorageService): Map<string, IViewState> {
|
||||
|
||||
private static loadViewsStates(workspaceViewsStateStorageId: string, globalViewsStateStorageId: string, storageService: IStorageService): Map<string, IViewState> {
|
||||
const viewStates = new Map<string, IViewState>();
|
||||
const storedViewsStates = JSON.parse(storageService.get(viewletStateStorageId, StorageScope.WORKSPACE, '{}'));
|
||||
const globalVisibilityStates = this.loadViewsVisibilityState(hiddenViewsStorageId, storageService, StorageScope.GLOBAL);
|
||||
const workspaceVisibilityStates = this.loadViewsVisibilityState(hiddenViewsStorageId, storageService, StorageScope.WORKSPACE);
|
||||
const workspaceViewsStates = <{ [id: string]: IStoredWorkspaceViewState }>JSON.parse(storageService.get(workspaceViewsStateStorageId, StorageScope.WORKSPACE, '{}'));
|
||||
for (const id of Object.keys(workspaceViewsStates)) {
|
||||
const workspaceViewState = workspaceViewsStates[id];
|
||||
viewStates.set(id, {
|
||||
visibleGlobal: undefined,
|
||||
visibleWorkspace: isUndefined(workspaceViewState.isHidden) ? undefined : !workspaceViewState.isHidden,
|
||||
collapsed: workspaceViewState.collapsed,
|
||||
order: workspaceViewState.order
|
||||
});
|
||||
}
|
||||
|
||||
for (const { id, isHidden } of values(globalVisibilityStates)) {
|
||||
const viewState = storedViewsStates[id];
|
||||
if (viewState) {
|
||||
viewStates.set(id, <IViewState>{ ...viewState, ...{ visibleGlobal: !isHidden } });
|
||||
} else {
|
||||
// New workspace
|
||||
viewStates.set(id, <IViewState>{ ...{ visibleGlobal: !isHidden } });
|
||||
// Migrate to `viewletStateStorageId`
|
||||
const workspaceVisibilityStates = this.loadGlobalViewsState(globalViewsStateStorageId, storageService, StorageScope.WORKSPACE);
|
||||
if (workspaceVisibilityStates.size > 0) {
|
||||
for (const { id, isHidden } of values(workspaceVisibilityStates)) {
|
||||
let viewState = viewStates.get(id);
|
||||
// Not migrated to `viewletStateStorageId`
|
||||
if (viewState) {
|
||||
if (isUndefined(viewState.visibleWorkspace)) {
|
||||
viewState.visibleWorkspace = !isHidden;
|
||||
}
|
||||
} else {
|
||||
viewStates.set(id, {
|
||||
collapsed: undefined,
|
||||
visibleGlobal: undefined,
|
||||
visibleWorkspace: !isHidden,
|
||||
});
|
||||
}
|
||||
}
|
||||
storageService.remove(globalViewsStateStorageId, StorageScope.WORKSPACE);
|
||||
}
|
||||
for (const { id, isHidden } of values(workspaceVisibilityStates)) {
|
||||
const viewState = storedViewsStates[id];
|
||||
|
||||
const globalViewsStates = this.loadGlobalViewsState(globalViewsStateStorageId, storageService, StorageScope.GLOBAL);
|
||||
for (const { id, isHidden, order } of values(globalViewsStates)) {
|
||||
let viewState = viewStates.get(id);
|
||||
if (viewState) {
|
||||
viewStates.set(id, <IViewState>{ ...viewState, ...{ visibleWorkspace: !isHidden } });
|
||||
viewState.visibleGlobal = !isHidden;
|
||||
if (!isUndefined(order)) {
|
||||
viewState.order = order;
|
||||
}
|
||||
} else {
|
||||
// New workspace
|
||||
viewStates.set(id, <IViewState>{ ...{ visibleWorkspace: !isHidden } });
|
||||
}
|
||||
}
|
||||
for (const id of Object.keys(storedViewsStates)) {
|
||||
if (!viewStates.has(id)) {
|
||||
viewStates.set(id, <IViewState>{ ...storedViewsStates[id] });
|
||||
viewStates.set(id, {
|
||||
visibleGlobal: !isHidden,
|
||||
order,
|
||||
collapsed: undefined,
|
||||
visibleWorkspace: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
return viewStates;
|
||||
}
|
||||
|
||||
private static loadViewsVisibilityState(hiddenViewsStorageId: string, storageService: IStorageService, scope: StorageScope): Map<string, { id: string, isHidden: boolean }> {
|
||||
const storedVisibilityStates = <Array<string | { id: string, isHidden: boolean }>>JSON.parse(storageService.get(hiddenViewsStorageId, scope, '[]'));
|
||||
private static loadGlobalViewsState(globalViewsStateStorageId: string, storageService: IStorageService, scope: StorageScope): Map<string, IStoredGlobalViewState> {
|
||||
const storedValue = <Array<string | IStoredGlobalViewState>>JSON.parse(storageService.get(globalViewsStateStorageId, scope, '[]'));
|
||||
let hasDuplicates = false;
|
||||
const storedViewsVisibilityStates = storedVisibilityStates.reduce((result, storedState) => {
|
||||
const storedGlobalViewsState = storedValue.reduce((result, storedState) => {
|
||||
if (typeof storedState === 'string' /* migration */) {
|
||||
hasDuplicates = hasDuplicates || result.has(storedState);
|
||||
result.set(storedState, { id: storedState, isHidden: true });
|
||||
@@ -578,13 +613,13 @@ export class PersistentContributableViewsModel extends ContributableViewsModel {
|
||||
result.set(storedState.id, storedState);
|
||||
}
|
||||
return result;
|
||||
}, new Map<string, { id: string, isHidden: boolean }>());
|
||||
}, new Map<string, IStoredGlobalViewState>());
|
||||
|
||||
if (hasDuplicates) {
|
||||
storageService.store(hiddenViewsStorageId, JSON.stringify(values(storedViewsVisibilityStates)), scope);
|
||||
storageService.store(globalViewsStateStorageId, JSON.stringify(values(storedGlobalViewsState)), scope);
|
||||
}
|
||||
|
||||
return storedViewsVisibilityStates;
|
||||
return storedGlobalViewsState;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ class CodeRendererMain extends Disposable {
|
||||
serviceCollection.set(IRemoteAuthorityResolverService, remoteAuthorityResolverService);
|
||||
|
||||
// Signing
|
||||
const signService = new SignService();
|
||||
const signService = new SignService(this.configuration.connectionToken);
|
||||
serviceCollection.set(ISignService, signService);
|
||||
|
||||
// Remote Agent
|
||||
|
||||
@@ -801,7 +801,7 @@ export class SimpleWindowsService implements IWindowsService {
|
||||
return Promise.resolve(this.windowCount);
|
||||
}
|
||||
|
||||
log(_severity: string, ..._messages: string[]): Promise<void> {
|
||||
log(_severity: string, _args: string[]): Promise<void> {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user