diff --git a/src/vs/editor/standalone/browser/standaloneThemeService.ts b/src/vs/editor/standalone/browser/standaloneThemeService.ts index e5230a0a757..cafca9f55a7 100644 --- a/src/vs/editor/standalone/browser/standaloneThemeService.ts +++ b/src/vs/editor/standalone/browser/standaloneThemeService.ts @@ -16,7 +16,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { asCssVariableName, ColorIdentifier, Extensions, IColorRegistry } from 'vs/platform/theme/common/colorRegistry'; import { Extensions as ThemingExtensions, ICssStyleCollector, IFileIconTheme, IProductIconTheme, IThemingRegistry, ITokenStyle } from 'vs/platform/theme/common/themeService'; import { IDisposable, Disposable } from 'vs/base/common/lifecycle'; -import { ColorScheme } from 'vs/platform/theme/common/theme'; +import { ColorScheme, isDark } from 'vs/platform/theme/common/theme'; import { getIconsStyleSheet, UnthemedProductIconTheme } from 'vs/platform/theme/browser/iconsStyleSheet'; const VS_THEME_NAME = 'vs'; @@ -242,6 +242,7 @@ export class StandaloneThemeService extends Disposable implements IStandaloneThe this._knownThemes.set(VS_THEME_NAME, newBuiltInTheme(VS_THEME_NAME)); this._knownThemes.set(VS_DARK_THEME_NAME, newBuiltInTheme(VS_DARK_THEME_NAME)); this._knownThemes.set(HC_BLACK_THEME_NAME, newBuiltInTheme(HC_BLACK_THEME_NAME)); + this._knownThemes.set(HC_LIGHT_THEME_NAME, newBuiltInTheme(HC_LIGHT_THEME_NAME)); const iconsStyleSheet = getIconsStyleSheet(this); @@ -339,10 +340,18 @@ export class StandaloneThemeService extends Disposable implements IStandaloneThe this._updateActualTheme(); } + private getHighContrastTheme() { + if (isDark(this._desiredTheme.type)) { + return HC_BLACK_THEME_NAME; + } else { + return HC_LIGHT_THEME_NAME; + } + } + private _updateActualTheme(): void { const theme = ( this._autoDetectHighContrast && window.matchMedia(`(forced-colors: active)`).matches - ? this._knownThemes.get(HC_BLACK_THEME_NAME)! + ? this._knownThemes.get(this.getHighContrastTheme())! : this._desiredTheme ); if (this._theme === theme) { diff --git a/src/vs/platform/theme/common/theme.ts b/src/vs/platform/theme/common/theme.ts index eabe6ecf497..856b2f12eb5 100644 --- a/src/vs/platform/theme/common/theme.ts +++ b/src/vs/platform/theme/common/theme.ts @@ -16,3 +16,7 @@ export enum ColorScheme { export function isHighContrast(scheme: ColorScheme): boolean { return scheme === ColorScheme.HIGH_CONTRAST_DARK || scheme === ColorScheme.HIGH_CONTRAST_LIGHT; } + +export function isDark(scheme: ColorScheme): boolean { + return scheme === ColorScheme.DARK || scheme === ColorScheme.HIGH_CONTRAST_DARK; +}