Skip to content

Make sure color themes handling in VS is up to date #16300

@majocha

Description

@majocha

Latest VS preview introduced refreshed UI, with lots of new color themes:
image

We have a mechanism that used to update F# specific semantic colors on theme change, to make sure there is enough contrast in dark and light themes:

let (|LightTheme|DarkTheme|UnknownTheme|) id =
if
id = KnownColorThemes.Light
|| id = KnownColorThemes.Blue
|| id = Guids.blueHighContrastThemeId
then
LightTheme
elif id = KnownColorThemes.Dark then
DarkTheme
else
UnknownTheme

Not only this will not detect any of the new themes, but this code also predates dark mode in Windows, so it does not properly handle "Use system setting" in VS:
image

In effect some code can get barely readable unless you set the colors by hand. Not a good first experience for newcomers etc.:
image

Looks like in the meantime Roslyn tackled that problem, too:
dotnet/roslyn#31976
dotnet/roslyn#39792
so we could probably look at their current state of things and borrow some ideas.
(There's a thing called ColorSchemeApplier, probably worth a look).

Some questions to consider:

  • do we still have to do it at runtime, or can it be handled when installing the vsix?
  • how to handle KnownColorThemes.System theme when it doesn't really tell us if it's dark or light? Maybe, instead of handling every VS theme possible, just peek at the editor window background color?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-VS-EditorVS editor support for F# code, not covered elsewhereBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions