Skip to content

Fix bad interaction with never opening window + terminate on last window #1260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ychin
Copy link
Member

@ychin ychin commented Aug 4, 2022

Previously, if you configure MacVim to never open an untitled window on launch, and terminate MacVim on last window closing, you could get an odd behavior where MacVim will close itself soon after launch, usually when you fiddle with "About MacVim" or the preference pane. This isn't too big a deal but could potentially make it hard to change the preference back, and it's hard to know if a future macOS update will further break this behavior causing MacVim to keep terminating itself on launch (the termination behavior relies on the applicationShouldTerminateAfterLastWindowClosed API which is controlled by the OS).

To fix this, simply make it so that the preference pane doesn't allow both settings to be set at once. If the user is trying to do so, set the other setting to be something sane. Also, in the applicationShouldTerminateAfterLastWindowClosed behavior, make sure we add additional protection so that it will not return true when we are set to never open untitled window (this should only be the case if the user manually set it using defaults because we are now already protecting against this in the preference pane logic). This should be fine because these two setting don't really make sense for the user anyway. It doesn't seem to make a lot of sense for the user to want this behavior.

Note that I'm doing manual checking in preference UI instead of using some sort of key-value listening of NSUserDefaults because I'm afraid of some unintentional infinite recursion going on where the settings keep setting each other back and forth. By only doing this at preference pane changes this should not happen.

Fix #1257

Previously, if you configure MacVim to never open an untitled window on
launch, *and* terminate MacVim on last window closing, you could get an
odd behavior where MacVim will close itself soon after launch, usually
when you fiddle with "About MacVim" or the preference pane. This isn't
too big a deal but could potentially make it hard to change the
preference back, and it's hard to know if a future macOS update will
further break this behavior causing MacVim to keep terminating itself on
launch (the termination behavior relies on the
`applicationShouldTerminateAfterLastWindowClosed` API which is
controlled by the OS).

To fix this, simply make it so that the preference pane doesn't allow
both settings to be set at once. If the user is trying to do so, set the
other setting to be something sane. Also, in the
`applicationShouldTerminateAfterLastWindowClosed` behavior, make sure we
add additional protection so that it will not return true when we are
set to never open untitled window (this should only be the case if the
user manually set it using `defaults` because we are now already
protecting against this in the preference pane logic). This should be
fine because these two setting don't really make sense for the user
anyway. It doesn't seem to make a lot of sense for the user to want this
behavior.

Note that I'm doing manual checking in preference UI instead of using
some sort of key-value listening of NSUserDefaults because I'm afraid of
some unintentional infinite recursion going on where the settings keep
setting each other back and forth. By only doing this at preference pane
changes this should not happen.

Fix macvim-dev#1257
@ychin ychin added this to the snapshot-174 milestone Aug 4, 2022
@ychin ychin merged commit 9fb0163 into macvim-dev:master Aug 4, 2022
@ychin ychin deleted the untitled-window-never-terminate-window-fix branch August 4, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MacVim closes when bringing up the "About MacVim" window when there are no other windows open
2 participants