Change:
Reproduced on OSS, Mac Steps to Reproduce: Code OSS a file cmd+w Closes the window Bisect points to this commit -
I can reproduce and this is likely context keys not being set properly because conditionally closes the window if no active editor. !
There are context keys that are now loose, for example
Follow up work

Discussion:
import { Disposable } from 'vs/base/common/lifecycle'; import { IContextKeyService, IContextKey, setConstant as setConstantContextKey } from 'vs/platform/contextkey/common/contextkey'; import { InputFocusedContext, IsMacContext, IsLinuxContext, IsWindowsContext, IsWebContext, IsMacNativeContext, IsDevelopmentContext, IsIOSContext, ProductQualityContext, IsMobileContext } from 'vs/platform/contextkey/common/contextkeys'; <del> import { SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, TitleBarVisibleContext, TitleBarStyleContext, IsAuxiliaryWindowFocusedContext } from 'vs/workbench/common/contextkeys'; </del> <ins> import { SplitEditorsVertically, InEditorZenModeContext, AuxiliaryBarVisibleContext, SideBarVisibleContext, PanelAlignmentContext, PanelMaximizedContext, PanelVisibleContext, EmbedderIdentifierContext, EditorTabsVisibleContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, DirtyWorkingCopiesContext, EmptyWorkspaceSupportContext, EnterMultiRootWorkspaceSupportContext, HasWebFileSystemAccess, IsMainWindowFullscreenContext, OpenFolderWorkspaceSupportContext, RemoteNameContext, VirtualWorkspaceContext, WorkbenchStateContext, WorkspaceFolderCountContext, PanelPositionContext, TemporaryWorkspaceContext, TitleBarVisibleContext, TitleBarStyleContext, IsAuxiliaryWindowFocusedContext, ActiveEditorGroupEmptyContext, ActiveEditorGroupIndexContext, ActiveEditorGroupLastContext, ActiveEditorGroupLockedContext, MultipleEditorGroupsContext, EditorsVisibleContext } from 'vs/workbench/common/contextkeys'; </ins> import { trackFocus, addDisposableListener, EventType, onDidRegisterWindow, getActiveWindow } from 'vs/base/browser/dom'; import { preferredSideBySideGroupDirection, GroupDirection, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';

import { getTitleBarStyle } from 'vs/platform/window/common/window'; import { mainWindow } from 'vs/base/browser/window'; import { isFullscreen, onDidChangeFullscreen } from 'vs/base/browser/browser'; <ins> import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; </ins> export class WorkbenchContextKeysHandler extends Disposable { private inputFocusedContext: IContextKey<boolean>; private dirtyWorkingCopiesContext: IContextKey<boolean>; <ins> private activeEditorGroupEmpty: IContextKey<boolean>; private activeEditorGroupIndex: IContextKey<number>; private activeEditorGroupLast: IContextKey<boolean>; private activeEditorGroupLocked: IContextKey<boolean>; private multipleEditorGroupsContext: IContextKey<boolean>; private editorsVisibleContext: IContextKey<boolean>; </ins> private splitEditorsVerticallyContext: IContextKey<boolean>; private workbenchStateContext: IContextKey<string>;

@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IProductService private readonly productService: IProductService, @IEditorGroupsService private readonly editorGroupService: IEditorGroupsService, <ins> @IEditorService private readonly editorService: IEditorService, </ins> @IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService, @IPaneCompositePartService private readonly paneCompositeService: IPaneCompositePartService, @IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,

ProductQualityContext.bindTo(this.contextKeyService).set(this.productService.quality || ''); EmbedderIdentifierContext.bindTo(this.contextKeyService).set(productService.embedderIdentifier); <ins> // Editor Groups this.activeEditorGroupEmpty = ActiveEditorGroupEmptyContext.bindTo(this.contextKeyService); this.activeEditorGroupIndex = ActiveEditorGroupIndexContext.bindTo(this.contextKeyService); this.activeEditorGroupLast = ActiveEditorGroupLastContext.bindTo(this.contextKeyService); this.activeEditorGroupLocked = ActiveEditorGroupLockedContext.bindTo(this.contextKeyService); this.multipleEditorGroupsContext = MultipleEditorGroupsContext.bindTo(this.contextKeyService); // Editors this.editorsVisibleContext = EditorsVisibleContext.bindTo(this.contextKeyService); </ins> // Working Copies this.dirtyWorkingCopiesContext = DirtyWorkingCopiesContext.bindTo(this.contextKeyService); this.dirtyWorkingCopiesContext.set(this.workingCopyService.hasDirty);

private registerListeners(): void { this.editorGroupService.whenReady.then(() => { this.updateEditorAreaContextKeys(); <ins> this.updateEditorGroupContextKeys(); this.updateVisiblePanesContextKeys(); </ins> }); <ins> this._register(this.editorService.onDidActiveEditorChange(() => this.updateEditorGroupContextKeys())); this._register(this.editorService.onDidVisibleEditorsChange(() => this.updateVisiblePanesContextKeys())); this._register(this.editorGroupService.onDidAddGroup(() => this.updateEditorGroupContextKeys())); this._register(this.editorGroupService.onDidRemoveGroup(() => this.updateEditorGroupContextKeys())); this._register(this.editorGroupService.onDidChangeGroupIndex(() => this.updateEditorGroupContextKeys())); this._register(this.editorGroupService.onDidChangeActiveGroup(() => this.updateEditorGroupsContextKeys())); this._register(this.editorGroupService.onDidChangeGroupLocked(() => this.updateEditorGroupsContextKeys())); </ins> this._register(this.editorGroupService.onDidChangeEditorPartOptions(() => this.updateEditorAreaContextKeys())); this._register(Event.runAndSubscribe(onDidRegisterWindow, ({ window, disposables }) => disposables.add(addDisposableListener(window, EventType.FOCUS_IN, () => this.updateInputContextKeys(window.document), true)), { window: mainWindow, disposables: this._store }));

this._register(this.workingCopyService.onDidChangeDirty(workingCopy => this.dirtyWorkingCopiesContext.set(workingCopy.isDirty() || this.workingCopyService.hasDirty))); } <ins> private updateVisiblePanesContextKeys(): void { const visibleEditorPanes = this.editorService.visibleEditorPanes; if (visibleEditorPanes.length > 0) { this.editorsVisibleContext.set(true); } else { this.editorsVisibleContext.reset(); } } private updateEditorGroupContextKeys(): void { if (!this.editorService.activeEditor) { this.activeEditorGroupEmpty.set(true); } else { this.activeEditorGroupEmpty.reset(); } this.updateEditorGroupsContextKeys(); } private updateEditorGroupsContextKeys(): void { const groupCount = this.editorGroupService.count; if (groupCount > 1) { this.multipleEditorGroupsContext.set(true); } else { this.multipleEditorGroupsContext.reset(); } const activeGroup = this.editorGroupService.activeGroup; this.activeEditorGroupIndex.set(activeGroup.index + 1); // not zero-indexed this.activeEditorGroupLast.set(activeGroup.index === groupCount - 1); this.activeEditorGroupLocked.set(activeGroup.isLocked); } </ins> private updateEditorAreaContextKeys(): void { this.editorTabsVisibleContext.set(this.editorGroupService.partOptions.showTabs === 'multiple'); }

const groupActiveEditorAvailableEditorIds = this.editorPartsView.bind(ActiveEditorAvailableEditorIdsContext, this); const groupActiveEditorCanSplitInGroupContext = this.editorPartsView.bind(ActiveEditorCanSplitInGroupContext, this); <del> const sideBySideEditorContext = this.editorPartsView.bind(SideBySideEditorActiveContext, this); </del> <ins> const groupActiveEditorIsSideBySideEditorContext = this.editorPartsView.bind(SideBySideEditorActiveContext, this); </ins> const activeEditorListener = this._register(new MutableDisposable());

if (activeEditor) { groupActiveEditorCanSplitInGroupContext.set(activeEditor.hasCapability(EditorInputCapabilities.CanSplitInGroup)); <del> sideBySideEditorContext.set(activeEditor.typeId === SideBySideEditorInput.ID); </del> <ins> groupActiveEditorIsSideBySideEditorContext.set(activeEditor.typeId === SideBySideEditorInput.ID); </ins> groupActiveEditorDirtyContext.set(activeEditor.isDirty() && !activeEditor.isSaving()); activeEditorListener.value = activeEditor.onDidChangeDirty(() => {

}); } else { groupActiveEditorCanSplitInGroupContext.set(false); <del> sideBySideEditorContext.set(false); </del> <ins> groupActiveEditorIsSideBySideEditorContext.set(false); </ins> groupActiveEditorDirtyContext.set(false); }