@@ -23,6 +23,7 @@ import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } fr
23
23
import { PartsSplash } from 'vs/workbench/electron-sandbox/splash' ;
24
24
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle' ;
25
25
import { InstallShellScriptAction , UninstallShellScriptAction } from 'vs/workbench/electron-sandbox/actions/installActions' ;
26
+ import { EditorsVisibleContext , SingleEditorGroupsContext } from 'vs/workbench/common/editor' ;
26
27
27
28
// Actions
28
29
( function registerActions ( ) : void {
@@ -37,6 +38,19 @@ import { InstallShellScriptAction, UninstallShellScriptAction } from 'vs/workben
37
38
registerAction2 ( QuickSwitchWindowAction ) ;
38
39
registerAction2 ( CloseWindowAction ) ;
39
40
41
+ if ( isMacintosh ) {
42
+ // macOS: behave like other native apps that have documents
43
+ // but can run without a document opened and allow to close
44
+ // the window when the last document is closed
45
+ // (https://github.com/microsoft/vscode/issues/126042)
46
+ KeybindingsRegistry . registerKeybindingRule ( {
47
+ id : CloseWindowAction . ID ,
48
+ weight : KeybindingWeight . WorkbenchContrib ,
49
+ when : ContextKeyExpr . and ( EditorsVisibleContext . toNegated ( ) , SingleEditorGroupsContext ) ,
50
+ primary : KeyMod . CtrlCmd | KeyCode . KEY_W
51
+ } ) ;
52
+ }
53
+
40
54
// Actions: Install Shell Script (macOS only)
41
55
if ( isMacintosh ) {
42
56
registerAction2 ( InstallShellScriptAction ) ;
0 commit comments