mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
revert: less pressure on storage service (fix #61255)
This commit is contained in:
@@ -25,7 +25,6 @@ import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
|
||||
import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart';
|
||||
import { StatusbarPart } from 'vs/workbench/browser/parts/statusbar/statusbarPart';
|
||||
import { getZoomFactor } from 'vs/base/browser/browser';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import * as perf from 'vs/base/common/performance';
|
||||
|
||||
const TITLE_BAR_HEIGHT = isMacintosh ? 22 : 30;
|
||||
@@ -69,8 +68,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
private _panelHeight: number;
|
||||
private _panelWidth: number;
|
||||
|
||||
private saveStateScheduler: RunOnceScheduler;
|
||||
|
||||
constructor(
|
||||
private parent: HTMLElement,
|
||||
private workbenchContainer: HTMLElement,
|
||||
@@ -103,9 +100,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
this.sashXTwo = new Sash(this.workbenchContainer, this);
|
||||
this.sashY = new Sash(this.workbenchContainer, this, { orientation: Orientation.HORIZONTAL });
|
||||
|
||||
// State scheduler
|
||||
this.saveStateScheduler = this._register(new RunOnceScheduler(() => this.saveState(), 800));
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
@@ -122,10 +116,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
private registerListeners(): void {
|
||||
this._register(this.themeService.onThemeChange(_ => this.layout()));
|
||||
this._register(this.parts.editor.onDidSizeConstraintsChange(() => this.onDidEditorSizeConstraintsChange()));
|
||||
this._register(this.storageService.onWillSaveState(() => {
|
||||
this.saveStateScheduler.dispose();
|
||||
this.saveState();
|
||||
}));
|
||||
|
||||
this.registerSashListeners();
|
||||
}
|
||||
@@ -383,21 +373,20 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
}));
|
||||
|
||||
this._register(this.sashXOne.onDidEnd(() => {
|
||||
this.saveStateScheduler.schedule();
|
||||
this.storageService.store(WorkbenchLayout.sashXOneWidthSettingsKey, this.sidebarWidth, StorageScope.GLOBAL);
|
||||
}));
|
||||
|
||||
this._register(this.sashY.onDidEnd(() => {
|
||||
this.saveStateScheduler.schedule();
|
||||
this.storageService.store(WorkbenchLayout.sashYHeightSettingsKey, this.panelHeight, StorageScope.GLOBAL);
|
||||
}));
|
||||
|
||||
this._register(this.sashXTwo.onDidEnd(() => {
|
||||
this.saveStateScheduler.schedule();
|
||||
this.storageService.store(WorkbenchLayout.sashXTwoWidthSettingsKey, this.panelWidth, StorageScope.GLOBAL);
|
||||
}));
|
||||
|
||||
this._register(this.sashY.onDidReset(() => {
|
||||
this.panelHeight = this.sidebarHeight * DEFAULT_PANEL_SIZE_COEFFICIENT;
|
||||
|
||||
this.saveStateScheduler.schedule();
|
||||
this.storageService.store(WorkbenchLayout.sashYHeightSettingsKey, this.panelHeight, StorageScope.GLOBAL);
|
||||
|
||||
this.layout();
|
||||
}));
|
||||
@@ -406,22 +395,20 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
let activeViewlet = this.viewletService.getActiveViewlet();
|
||||
let optimalWidth = activeViewlet && activeViewlet.getOptimalWidth();
|
||||
this.sidebarWidth = Math.max(optimalWidth, DEFAULT_SIDEBAR_PART_WIDTH);
|
||||
|
||||
this.saveStateScheduler.schedule();
|
||||
this.storageService.store(WorkbenchLayout.sashXOneWidthSettingsKey, this.sidebarWidth, StorageScope.GLOBAL);
|
||||
|
||||
this.partService.setSideBarHidden(false).then(() => this.layout());
|
||||
}));
|
||||
|
||||
this._register(this.sashXTwo.onDidReset(() => {
|
||||
this.panelWidth = (this.workbenchSize.width - this.sidebarWidth - this.activitybarWidth) * DEFAULT_PANEL_SIZE_COEFFICIENT;
|
||||
|
||||
this.saveStateScheduler.schedule();
|
||||
this.storageService.store(WorkbenchLayout.sashXTwoWidthSettingsKey, this.panelWidth, StorageScope.GLOBAL);
|
||||
|
||||
this.layout();
|
||||
}));
|
||||
}
|
||||
|
||||
layout(options?: ILayoutOptions): void { //
|
||||
layout(options?: ILayoutOptions): void {
|
||||
this.workbenchSize = getClientArea(this.parent);
|
||||
|
||||
const isActivityBarHidden = !this.partService.isVisible(Parts.ACTIVITYBAR_PART);
|
||||
@@ -490,6 +477,8 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
}
|
||||
}
|
||||
|
||||
this.storageService.store(WorkbenchLayout.panelSizeBeforeMaximizedKey, this.panelSizeBeforeMaximized, StorageScope.GLOBAL);
|
||||
|
||||
const panelDimension = new Dimension(panelWidth, panelHeight);
|
||||
|
||||
// Editor
|
||||
@@ -544,13 +533,16 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
|
||||
if (!isSidebarHidden) {
|
||||
this.sidebarWidth = sidebarSize.width;
|
||||
this.storageService.store(WorkbenchLayout.sashXOneWidthSettingsKey, this.sidebarWidth, StorageScope.GLOBAL);
|
||||
}
|
||||
|
||||
if (!isPanelHidden) {
|
||||
if (panelPosition === Position.BOTTOM) {
|
||||
this.panelHeight = panelDimension.height;
|
||||
this.storageService.store(WorkbenchLayout.sashYHeightSettingsKey, this.panelHeight, StorageScope.GLOBAL);
|
||||
} else {
|
||||
this.panelWidth = panelDimension.width;
|
||||
this.storageService.store(WorkbenchLayout.sashXTwoWidthSettingsKey, this.panelWidth, StorageScope.GLOBAL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,9 +662,6 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
|
||||
// Propagate to Context View
|
||||
this.contextViewService.layout();
|
||||
|
||||
// Schedule save state
|
||||
this.saveStateScheduler.schedule();
|
||||
}
|
||||
|
||||
getVerticalSashTop(sash: Sash): number {
|
||||
@@ -774,13 +763,4 @@ export class WorkbenchLayout extends Disposable implements IVerticalSashLayoutPr
|
||||
this.layout();
|
||||
}
|
||||
}
|
||||
|
||||
private saveState(): void {
|
||||
this.storageService.store(WorkbenchLayout.sashXOneWidthSettingsKey, this.sidebarWidth, StorageScope.GLOBAL);
|
||||
|
||||
this.storageService.store(WorkbenchLayout.sashYHeightSettingsKey, this.panelHeight, StorageScope.GLOBAL);
|
||||
this.storageService.store(WorkbenchLayout.sashXTwoWidthSettingsKey, this.panelWidth, StorageScope.GLOBAL);
|
||||
|
||||
this.storageService.store(WorkbenchLayout.panelSizeBeforeMaximizedKey, this.panelSizeBeforeMaximized, StorageScope.GLOBAL);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user