microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.4k stars 8.3k forks source link

Using an Unfocused Appearance resets any runtime palette and cursor changes #11990

Open j4james opened 2 years ago

j4james commented 2 years ago

Windows Terminal version

1.12.3472.0

Windows build number

10.0.19041.1348

Other Software

No response

Steps to reproduce

  1. Open the Settings in Windows Terminal and go to the Profiles Defaults section.
  2. On the Appearance tab, enable the Unfocused Appearance option (you don't need to change any of the properties though).
  3. Open a WSL bash shell.
  4. Change the default background palette to red using an OSC 11 sequence: printf "\e]11;rgb:44/00/00\e\\"
  5. Change the cursor shape to a filled box (something other than your default) with a DECSCUSR sequence: printf "\e[1 q"
  6. Switch focus to another application and then switch back again.

Expected Behavior

When the focus returns, I'd expect the background color to be red again, and the cursor to be a filled box again.

Actual Behavior

The background color changes back to the original color scheme, and the cursor returns to the original value in the settings.

I'm not sure there is a good way to fix this though. Perhaps we should be saving the active settings when the app loses focus, and then restoring them when it gains focus again, rather than resetting everything? That doesn't handle all edge case, but it's probably better than nothing.

Otherwise I suppose we could say that runtime changes to these settings aren't expected to work if you've configured an Unfocused Appearance. But if we're going to take that approach, then I think we should really be disabling those sequences completely. Having them appear to work, but then get "randomly" reset just seems like a bug.

Archomeda commented 2 weeks ago

I came across this problem as well in #17997. It resets my background color back to its original color when using this feature.

Also another note: this also occurs when ctrl+tabbing between tabs.