macvim-dev / macvim

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

v:os_appearance doesn't match system #1479

Closed halilim closed 4 months ago

halilim commented 4 months ago

Steps to reproduce

  1. Enable OS dark mode (System Settings > Appearance > Dark)
  2. Verify: defaults read -g AppleInterfaceStyle # => Dark
  3. Check MacVim value mvim --clean +'echo v:os_appearance' # => 0 Can be replicated by opening the app outside of the terminal and typing :echo v:os_appearance

Expected behaviour

MacVim echoes 1

Version of Vim and architecture

MacVim r179 (Vim 9.1.0), arm64

Environment

How MacVim was installed

Homebrew

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

ychin commented 4 months ago

That's weird. Seems like it got broken somehow. May need to bisect this and add a test for it. Thanks for reporting.

ychin commented 4 months ago

Hi @halilim , after looking more into it, I think the API is working as designed. MacVim is reading the appearance mode of its own window, which will be the OS appearance mode if you have "Dark mode selection" set to "Automatic" in Settings->Appearance. If you have manually overridden it to "Light mode"/"Dark mode"/"Use 'background' option" then MacVim will always report the mode that is being set there instead of the OS one.

Since I think the current behavior mostly makes sense, and that this has been how it works for a while, I'm not too inclined to change the behavior. Can you describe what you are trying to use it for? Meanwhile I can update the documentation to make it clearer exactly what v:os_appearance is reporting.

I can definitely see some edge cases where you may want to rely on "Use 'background' option" in the setting, but still be able to query the OS appearance mode, so I could see some ways the current behavior is problematic.

halilim commented 4 months ago

Hi @ychin, thank you for your response. I was using the macOS dark mode setting. I completely forgot about the dark mode setting of the app itself, which was set to Use 'background' option. I now set it to Automatic, and it works perfectly fine. I'm sorry for taking your time, thank you again. (FWIW, I use this for mode change automation via OSAppearanceChanged).