diff --git a/src/vs/platform/storage/node/storageService.ts b/src/vs/platform/storage/node/storageService.ts index 6219b67317aa30e70bd15ccf30c4fe5e776958c0..7cd48b4d7cf05d03e7692ac5da0a966c4500b351 100644 --- a/src/vs/platform/storage/node/storageService.ts +++ b/src/vs/platform/storage/node/storageService.ts @@ -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', diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 0aaba8ded7b3ee63450c2c588be516cd5fa8e0f7..5a0672cf2152e830bcc467fd829d30b0ac56bdf6 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -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('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[] { @@ -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('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); } } diff --git a/src/vs/workbench/services/history/electron-browser/history.ts b/src/vs/workbench/services/history/electron-browser/history.ts index fd453024d03b7751395b7cf3b53c7f14d3353e20..a77deb474c0e66db62332caae07344c043d6a584 100644 --- a/src/vs/workbench/services/history/electron-browser/history.ts +++ b/src/vs/workbench/services/history/electron-browser/history.ts @@ -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())); }