@@ -548,17 +548,15 @@ - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
548548
549549- (BOOL )applicationShouldTerminateAfterLastWindowClosed : (NSApplication *)sender
550550{
551- if (MMUntitledWindowNever ==
552- [[NSUserDefaults standardUserDefaults ]
553- integerForKey: MMUntitledWindowKey]) {
554- // Sanity protection: If we never open a new window on application launch, there could
555- // be an issue here where we immediately terminate MacVim. Because of that, we always
556- // return false regardless of what MMLastWindowClosedBehavior is. Note that the user
557- // should not be able to set these two conflicting options together in the preference pane
558- // but it's possible to do so in the terminal by calling "defaults" manually.
559- return false ;
551+ if (!hasShownWindowBefore) {
552+ // If we have not opened a window before, never return YES. This can
553+ // happen when MacVim is not configured to open window at launch. We
554+ // want to give the user a chance to open a window first. Otherwise
555+ // just opening the About MacVim or Settings windows could immediately
556+ // terminate the app (since those are not proper app windows),
557+ // depending if the OS feels like invoking this method.
558+ return NO ;
560559 }
561-
562560 return (MMTerminateWhenLastWindowClosed ==
563561 [[NSUserDefaults standardUserDefaults ]
564562 integerForKey: MMLastWindowClosedBehaviorKey]);
@@ -899,6 +897,8 @@ - (void)windowControllerWillOpen:(MMWindowController *)windowController
899897 [NSApp activateIgnoringOtherApps: YES ];
900898 shouldActivateWhenNextWindowOpens = NO ;
901899 }
900+
901+ hasShownWindowBefore = YES ;
902902}
903903
904904- (void )setMainMenu : (NSMenu *)mainMenu
0 commit comments