提交 b782c3a6 编写于 作者: B Benjamin Pasero

storage - avoid storage access on shutdown

上级 e7bfb7b0
......@@ -199,7 +199,6 @@ export class StorageService extends Disposable implements IStorageService {
'workbench.panelpart.activepanelid',
'workbench.zenmode.active',
'workbench.centerededitorlayout.active',
'workbench.sidebar.restore',
'workbench.sidebar.hidden',
'workbench.panel.hidden',
'workbench.panel.location',
......
......@@ -72,7 +72,7 @@ import { ProgressService2 } from 'vs/workbench/services/progress/browser/progres
import { TextModelResolverService } from 'vs/workbench/services/textmodelResolver/common/textModelResolverService';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ShutdownReason, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { LifecyclePhase, StartupKind } from 'vs/platform/lifecycle/common/lifecycle';
import { LifecycleService } from 'vs/platform/lifecycle/electron-browser/lifecycleService';
import { IWindowService, IWindowConfiguration, IPath, MenuBarVisibility, getTitleBarStyle } from 'vs/platform/windows/common/windows';
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
......@@ -171,7 +171,6 @@ export class Workbench extends Disposable implements IPartService {
private static readonly sidebarHiddenStorageKey = 'workbench.sidebar.hidden';
private static readonly menubarVisibilityConfigurationKey = 'window.menuBarVisibility';
private static readonly sidebarRestoreStorageKey = 'workbench.sidebar.restore';
private static readonly panelHiddenStorageKey = 'workbench.panel.hidden';
private static readonly zenModeActiveStorageKey = 'workbench.zenmode.active';
private static readonly centeredEditorLayoutActiveStorageKey = 'workbench.centerededitorlayout.active';
......@@ -476,8 +475,8 @@ export class Workbench extends Disposable implements IPartService {
private registerListeners(): void {
// Lifecycle
this._register(this.lifecycleService.onBeforeShutdown(e => this.saveState(e.reason)));
// Storage
this._register(this.storageService.onWillSaveState(() => this.saveState()));
// Listen to visible editor changes
this._register(this.editorService.onDidVisibleEditorsChange(() => this.onDidVisibleEditorsChange()));
......@@ -758,8 +757,10 @@ export class Workbench extends Disposable implements IPartService {
perf.mark('didRestorePanel');
}
// Restore Zen Mode if active
if (this.storageService.getBoolean(Workbench.zenModeActiveStorageKey, StorageScope.WORKSPACE, false)) {
// Restore Zen Mode if active and supported for restore on startup
const zenConfig = this.configurationService.getValue<IZenModeSettings>('zenMode');
const wasZenActive = this.storageService.getBoolean(Workbench.zenModeActiveStorageKey, StorageScope.WORKSPACE, false);
if (wasZenActive && (zenConfig.restore || this.lifecycleService.startupKind === StartupKind.ReloadedWindow)) {
this.toggleZenMode(true, true);
}
......@@ -802,12 +803,8 @@ export class Workbench extends Disposable implements IPartService {
return true; // always restore sidebar when we are in development mode
}
const restore = this.storageService.getBoolean(Workbench.sidebarRestoreStorageKey, StorageScope.WORKSPACE);
if (restore) {
this.storageService.remove(Workbench.sidebarRestoreStorageKey, StorageScope.WORKSPACE); // only support once
}
return restore;
// always restore sidebar when the window was reloaded
return this.lifecycleService.startupKind === StartupKind.ReloadedWindow;
}
private resolveEditorsToOpen(): Thenable<IResourceEditor[]> | IResourceEditor[] {
......@@ -1121,23 +1118,10 @@ export class Workbench extends Disposable implements IPartService {
return this.instantiationService;
}
private saveState(reason: ShutdownReason): void {
// Restore sidebar if we are being shutdown as a matter of a reload
if (reason === ShutdownReason.RELOAD) {
this.storageService.store(Workbench.sidebarRestoreStorageKey, true, StorageScope.WORKSPACE);
}
// Preserve zen mode only on reload. Real quit gets out of zen mode so novice users do not get stuck in zen mode.
const zenConfig = this.configurationService.getValue<IZenModeSettings>('zenMode');
const restoreZenMode = this.zenMode.active && (zenConfig.restore || reason === ShutdownReason.RELOAD);
if (restoreZenMode) {
private saveState(): void {
if (this.zenMode.active) {
this.storageService.store(Workbench.zenModeActiveStorageKey, true, StorageScope.WORKSPACE);
} else {
if (this.zenMode.active) {
this.toggleZenMode(true);
}
this.storageService.remove(Workbench.zenModeActiveStorageKey, StorageScope.WORKSPACE);
}
}
......
......@@ -175,7 +175,7 @@ export class HistoryService extends Disposable implements IHistoryService {
this._register(this.editorService.onDidActiveEditorChange(() => this.onActiveEditorChanged()));
this._register(this.editorService.onDidOpenEditorFail(event => this.remove(event.editor)));
this._register(this.editorService.onDidCloseEditor(event => this.onEditorClosed(event)));
this._register(this.storageService.onWillSaveState(reason => this.saveState()));
this._register(this.storageService.onWillSaveState(() => this.saveState()));
this._register(this.fileService.onFileChanges(event => this.onFileChanges(event)));
this._register(this.resourceFilter.onExpressionChange(() => this.handleExcludesChange()));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册