Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new default theme: check setting when patching initial colors #180687

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as nls from 'vs/nls';
import * as types from 'vs/base/common/types';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IWorkbenchThemeService, IWorkbenchColorTheme, IWorkbenchFileIconTheme, ExtensionData, VS_LIGHT_THEME, VS_DARK_THEME, VS_HC_THEME, VS_HC_LIGHT_THEME, ThemeSettings, IWorkbenchProductIconTheme, ThemeSettingTarget, ThemeSettingDefaults } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IWorkbenchThemeService, IWorkbenchColorTheme, IWorkbenchFileIconTheme, ExtensionData, VS_LIGHT_THEME, VS_DARK_THEME, VS_HC_THEME, VS_HC_LIGHT_THEME, ThemeSettings, IWorkbenchProductIconTheme, ThemeSettingTarget, ThemeSettingDefaults, COLOR_THEME_DARK_INITIAL_COLORS, COLOR_THEME_LIGHT_INITIAL_COLORS } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Registry } from 'vs/platform/registry/common/platform';
Expand Down Expand Up @@ -143,7 +143,8 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
// themes are loaded asynchronously, we need to initialize
// a color theme document with good defaults until the theme is loaded
let themeData: ColorThemeData | undefined = ColorThemeData.fromStorageData(this.storageService);
if (themeData && this.settings.colorTheme !== themeData.settingsId && this.settings.isDefaultColorTheme()) {
const colorThemeSetting = this.settings.colorTheme;
if (themeData && colorThemeSetting !== themeData.settingsId && this.settings.isDefaultColorTheme()) {
this.hasDefaultUpdated = themeData.settingsId === ThemeSettingDefaults.COLOR_THEME_DARK_OLD || themeData.settingsId === ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD;

// the web has different defaults than the desktop, therefore do not restore when the setting is the default theme and the storage doesn't match that.
Expand All @@ -152,18 +153,19 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {

// the preferred color scheme (high contrast, light, dark) has changed since the last start
const preferredColorScheme = this.getPreferredColorScheme();
const defaultColorMap = colorThemeSetting === ThemeSettingDefaults.COLOR_THEME_LIGHT ? COLOR_THEME_LIGHT_INITIAL_COLORS : colorThemeSetting === ThemeSettingDefaults.COLOR_THEME_DARK ? COLOR_THEME_DARK_INITIAL_COLORS : undefined;

if (preferredColorScheme && themeData?.type !== preferredColorScheme && this.storageService.get(PERSISTED_OS_COLOR_SCHEME, PERSISTED_OS_COLOR_SCHEME_SCOPE) !== preferredColorScheme) {
themeData = ColorThemeData.createUnloadedThemeForThemeType(preferredColorScheme);
themeData = ColorThemeData.createUnloadedThemeForThemeType(preferredColorScheme, undefined);
}
if (!themeData) {
const initialColorTheme = environmentService.options?.initialColorTheme;
if (initialColorTheme) {
themeData = ColorThemeData.createUnloadedThemeForThemeType(initialColorTheme.themeType, initialColorTheme.colors);
themeData = ColorThemeData.createUnloadedThemeForThemeType(initialColorTheme.themeType, initialColorTheme.colors ?? defaultColorMap);
}
}
if (!themeData) {
themeData = ColorThemeData.createUnloadedThemeForThemeType(isWeb ? ColorScheme.LIGHT : ColorScheme.DARK);
themeData = ColorThemeData.createUnloadedThemeForThemeType(isWeb ? ColorScheme.LIGHT : ColorScheme.DARK, defaultColorMap);
}
themeData.setCustomizations(this.settings);
this.applyTheme(themeData, undefined, true);
Expand Down
16 changes: 0 additions & 16 deletions src/vs/workbench/services/themes/common/colorThemeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,22 +587,6 @@ export class ColorThemeData implements IWorkbenchColorTheme {
// constructors

static createUnloadedThemeForThemeType(themeType: ColorScheme, colorMap?: { [id: string]: string }): ColorThemeData {
if (!colorMap) {
if (themeType === ColorScheme.LIGHT) {
colorMap = {
'activityBar.background': '#f8f8f8',
'statusBar.background': '#f8f8f8',
'statusBar.noFolderBackground': '#f8f8f8'
};
} else {
colorMap = {
'activityBar.background': '#181818',
'statusBar.background': '#181818',
'statusBar.noFolderBackground': '#1f1f1f',
};
}

}
return ColorThemeData.createUnloadedTheme(getThemeTypeSelector(themeType), colorMap);
}

Expand Down
14 changes: 13 additions & 1 deletion src/vs/workbench/services/themes/common/workbenchThemeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,21 @@ export enum ThemeSettingDefaults {
COLOR_THEME_LIGHT_OLD = 'Default Light+',

FILE_ICON_THEME = 'vs-seti',
PRODUCT_ICON_THEME = 'Default'
PRODUCT_ICON_THEME = 'Default',
}

export const COLOR_THEME_DARK_INITIAL_COLORS = {
'activityBar.background': '#181818',
'statusBar.background': '#181818',
'statusBar.noFolderBackground': '#1f1f1f',
};

export const COLOR_THEME_LIGHT_INITIAL_COLORS = {
'activityBar.background': '#f8f8f8',
'statusBar.background': '#f8f8f8',
'statusBar.noFolderBackground': '#f8f8f8'
};

export interface IWorkbenchTheme {
readonly id: string;
readonly label: string;
Expand Down