macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.53k stars 685 forks source link

MacVim closes when bringing up the "About MacVim" window when there are no other windows open #1257

Closed jwanja closed 2 years ago

jwanja commented 2 years ago

Steps to reproduce

  1. Open MacVim with no windows (see Note below)
  2. Navigate to and click the "About MacVim" menu item in the menu bar
  3. The about MacVim window flashes and then disappears

I have a hunch that the issue is from the combination of these two options:

  1. Open untitled window === "never"
  2. After last window closes === "Quit MacVim"

If I open a blank window or change the "After last window closes" option to "Keep MacVim Running", the About MacVIm window will stay open.

Expected behaviour

Be able to view the "About MacVim" window at any time and with any settings configuration.

Version of Vim and architecture

9.0.65

Environment

Monterey 12.4 iTerm 2 "xterm-256color"

How MacVim was installed

GitHub

Logs and stack traces

No response

Vim configuration where issue is reproducable

No response

Issue has been tested with given configuration

Issue has been tested with no configuration

Other conditions

jwanja commented 2 years ago

Also I just realized if I press any menu bar item, e.g "MacVim", "File", "Edit", etc., and then press the menu bar item again, the application will close.

ychin commented 2 years ago

Oh that’s interesting. Does seem like a bug.

Just out of curiosity though why would you have those two options? It seems somewhat contradictory and I’m curious why someone would configure MacVim that way.

eirnym commented 2 years ago

I've tested with the latest MacVim 9.0.65 (173) on Catalina.

  1. I set the options below and reload MacVim
    • Open untitled window === "never"
    • After last window closes === "Quit MacVim"
  2. I opened MacVim and opened preferences window, closed it without changes and MacVim exited which agree with my understanding of "Quit after last window closes"
  3. I opened MacVim and opened about window, closed it without changes and MacVim exited which agree with my understanding of "Quit after last window closes"
  4. I opened settings and new editor window. Closing one of windows doesn't quit the app, which agree with my understanding of "Quit after last window closes"

Could you please explain me, where is the contradiction?

jwanja commented 2 years ago

@ychin it 100% is contradictory to have the settings configured the way I did. I've already changed those options to something sane, but I couldn't help but investigate what was happening when the About screen disappeared immediately when I opened it up.

I have a unique use case since I'm using MacVim as a proxy to have a reliably updated vim executable since my company blocked homebrew on our machines. For the most part I'm using vim in a terminal and have aliased it to point to MacVim's instance of vim. I really only open the GUI when I need to open a large file to search around in faster than TextEdit, or when I feel like it has been a while since I've updated MacVim and more importantly updated the vim version.

jwanja commented 2 years ago

I've tested with the latest MacVim 9.0.65 (173) on Catalina.

  1. I set the options below and reload MacVim

    • Open untitled window === "never"
    • After last window closes === "Quit MacVim"
  2. I opened MacVim and opened preferences window, closed it without changes and MacVim exited which agree with my understanding of "Quit after last window closes"
  3. I opened MacVim and opened about window, closed it without changes and MacVim exited which agree with my understanding of "Quit after last window closes"
  4. I opened settings and new editor window. Closing one of windows doesn't quit the app, which agree with my understanding of "Quit after last window closes"

Could you please explain me, where is the contradiction?

@eirnym for me, step 3 has a different behavior. When I choose the option to open the About MacVim window, if it will be the only window owned by MacVim, it flashes on screen very quickly, then automatically closes itself, and then MacVim exits.

eirnym commented 2 years ago

I observe the flash, but it's not doing every time I close MacVim and I can't consistently say, that this is any kind of a ghost window or not.

Additionally, I observe similar flashing when closing Terminal.app, Preview.app and few others I've just tested when I close the app which has no open windows left. This flash is not quite visible when there's no opened browser with 100 tabs spread to few windows opened. I believe the opening and the closing animations are played independently if there're any opened windows or not.

Could you try to disable or minimize closing macOS animations by using ui tweaks or changing defaults?

ychin commented 2 years ago

This setting is done by using the applicationShouldTerminateAfterLastWindowClosed API. It's kind of up to macOS when it calls it and when it feels like closing the application, so maybe it depends on different conditions.

I think I will just make it clear that the options of "Open untitled window === never" and "After last window closes === Quit MacVim" cannot be set together. Maybe add some preference pane logic to make it so as well, and/or enforcing this mutual exclusion in the code. It just doesn't make sense to have them set together, as by definition macOS should immediately close the app. In fact I wonder if in a future version of macOS, having those options set together would cause MacVim to keep closing itself causing the user to never be able to change the setting in the preference pane which would be bad, so this should be fixed (the user can obviously still use the terminal to set it using defaults, but that's not ideal).