From 46e453dc1cf18b58d986bee46db181544792d78e Mon Sep 17 00:00:00 2001 From: isidor Date: Mon, 3 Dec 2018 12:05:05 +0100 Subject: [PATCH 1/2] zen mode: We will not restore zen mode, need to clear all zen mode state changes --- src/vs/workbench/electron-browser/workbench.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 5a0672cf215..fc7b860aa7c 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 { LifecyclePhase, StartupKind } from 'vs/platform/lifecycle/common/lifecycle'; +import { LifecyclePhase, StartupKind, ShutdownReason } 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'; @@ -500,6 +500,15 @@ export class Workbench extends Disposable implements IPartService { // Group changes this._register(this.editorGroupService.onDidAddGroup(() => this.centerEditorLayout(this.shouldCenterLayout))); this._register(this.editorGroupService.onDidRemoveGroup(() => this.centerEditorLayout(this.shouldCenterLayout))); + + this._register(this.lifecycleService.onWillShutdown(e => { + const zenConfig = this.configurationService.getValue('zenMode'); + const willRestoreZenMode = this.zenMode.active && (zenConfig.restore || e.reason === ShutdownReason.RELOAD); + if (!willRestoreZenMode) { + // We will not restore zen mode, need to clear all zen mode state changes + this.toggleZenMode(true); + } + })); } private onFullscreenChanged(): void { From 2d57133894da54c6e7f6d69ee4cf841dbcf7ecd6 Mon Sep 17 00:00:00 2001 From: isidor Date: Mon, 3 Dec 2018 15:25:50 +0100 Subject: [PATCH 2/2] zen mode: properly clear state on shutdown --- .../workbench/electron-browser/workbench.ts | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index fc7b860aa7c..35bc4a82b31 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -36,7 +36,7 @@ import { QuickInputService } from 'vs/workbench/browser/parts/quickinput/quickIn import { getServices } from 'vs/platform/instantiation/common/extensions'; import { Position, Parts, IPartService, ILayoutOptions, IDimension, PositionToString } from 'vs/workbench/services/part/common/partService'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; -import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; +import { IStorageService, StorageScope, IWillSaveStateEvent, WillSaveStateReason } from 'vs/platform/storage/common/storage'; import { ContextMenuService as NativeContextMenuService } from 'vs/workbench/services/contextview/electron-browser/contextmenuService'; import { ContextMenuService as HTMLContextMenuService } from 'vs/platform/contextview/browser/contextMenuService'; import { WorkbenchKeybindingService } from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; @@ -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 { LifecyclePhase, StartupKind, ShutdownReason } 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'; @@ -476,7 +476,7 @@ export class Workbench extends Disposable implements IPartService { private registerListeners(): void { // Storage - this._register(this.storageService.onWillSaveState(() => this.saveState())); + this._register(this.storageService.onWillSaveState(e => this.saveState(e))); // Listen to visible editor changes this._register(this.editorService.onDidVisibleEditorsChange(() => this.onDidVisibleEditorsChange())); @@ -500,15 +500,6 @@ export class Workbench extends Disposable implements IPartService { // Group changes this._register(this.editorGroupService.onDidAddGroup(() => this.centerEditorLayout(this.shouldCenterLayout))); this._register(this.editorGroupService.onDidRemoveGroup(() => this.centerEditorLayout(this.shouldCenterLayout))); - - this._register(this.lifecycleService.onWillShutdown(e => { - const zenConfig = this.configurationService.getValue('zenMode'); - const willRestoreZenMode = this.zenMode.active && (zenConfig.restore || e.reason === ShutdownReason.RELOAD); - if (!willRestoreZenMode) { - // We will not restore zen mode, need to clear all zen mode state changes - this.toggleZenMode(true); - } - })); } private onFullscreenChanged(): void { @@ -769,7 +760,7 @@ export class Workbench extends Disposable implements IPartService { // 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)) { + if (wasZenActive && zenConfig.restore) { this.toggleZenMode(true, true); } @@ -1127,12 +1118,20 @@ export class Workbench extends Disposable implements IPartService { return this.instantiationService; } - private saveState(): void { + private saveState(e: IWillSaveStateEvent): void { if (this.zenMode.active) { this.storageService.store(Workbench.zenModeActiveStorageKey, true, StorageScope.WORKSPACE); } else { this.storageService.remove(Workbench.zenModeActiveStorageKey, StorageScope.WORKSPACE); } + + if (e.reason === WillSaveStateReason.SHUTDOWN && this.zenMode.active) { + const zenConfig = this.configurationService.getValue('zenMode'); + if (!zenConfig.restore) { + // We will not restore zen mode, need to clear all zen mode state changes + this.toggleZenMode(true); + } + } } dispose(): void {