Change:
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'; <del> import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; </del> <ins> import { IStorageService, StorageScope, IWillSaveStateEvent, WillSaveStateReason } from 'vs/platform/storage/common/storage'; </ins> 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';

Discussion:
zen mode vscode, start vscode that zen mode properly is not restored excepted centered layout. Centered layout should also be inactive (since is )
acutally your change from that commit caused this. You removed that the zen mode gets out of zen mode when you are exiting. Let me look into a fix
the idea is to only write to local storage from and not . Is writing any data to local storage? If not, this change seems fine.
it is writing data to local storage. I just need to write it before the workbench goes down. So I will react on instead of . That event will only get fired once before the workbench shuts down?
yeah currently that is right. In the future when we decide to store state more periodically we might decide to call this method more often though to preserve state even if Code is crashing. I do not understand why you have to leave Zen mode on shutdown because you will restore it on the next startup, no? Given that, I suggest to NOT leave Zen mode on shutdown but rather simply NOT restore it on next startup. Isn't that easier?
thanks for clarification. I can not simply NOT restore it on next startup since the subsets of zen mode will have written state to storage. Example: User enters zen mode -zen mode tells Sidebar hide yourself. Sidebar writes that into storage Next vscode start -zen mode is not restored, Sidebar is still hidden because he wrote into storage once we activated zen mode. Due to how the feature is designed it needs to explicitly tell the underlying parts to hide or show. We could change this, but that would require that every underlying part is aware of zen mode which might overcomplicate things. Suggestions on how to tackle this are also welcome Thanks
got it. I pushed a change so that carries a with a reason you can ask for. On shutdown that reason will be set and so you can do the same things as before. As long as you are not running async code that accesses storage late, things should be fine. The goal should be that storage layer gets accessed either: when changes happen (e.g. workbench layout does that) or (which currently only fires on shutdown but might fire periodically later)
this works.

However there was a corner case for the reload since we were restoring zen mode always on reload and in your event i was not getting if it is a reload or regular shutdown Though fixed it by not auto restoring zen mode on reload. I think this is perfectly fine. Users should set zenMode.restore to true if they want this
thank you