Skip to content

Commit 6bd5fe0

Browse files
authored
new default theme: check setting when patching initial colors (microsoft#180687)
* new default theme: check setting when patching initial colors * remove unneeded imports
1 parent fc5b15d commit 6bd5fe0

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

src/vs/workbench/services/themes/browser/workbenchThemeService.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as nls from 'vs/nls';
77
import * as types from 'vs/base/common/types';
88
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
9-
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';
9+
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';
1010
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
1111
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1212
import { Registry } from 'vs/platform/registry/common/platform';
@@ -143,7 +143,8 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
143143
// themes are loaded asynchronously, we need to initialize
144144
// a color theme document with good defaults until the theme is loaded
145145
let themeData: ColorThemeData | undefined = ColorThemeData.fromStorageData(this.storageService);
146-
if (themeData && this.settings.colorTheme !== themeData.settingsId && this.settings.isDefaultColorTheme()) {
146+
const colorThemeSetting = this.settings.colorTheme;
147+
if (themeData && colorThemeSetting !== themeData.settingsId && this.settings.isDefaultColorTheme()) {
147148
this.hasDefaultUpdated = themeData.settingsId === ThemeSettingDefaults.COLOR_THEME_DARK_OLD || themeData.settingsId === ThemeSettingDefaults.COLOR_THEME_LIGHT_OLD;
148149

149150
// 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.
@@ -152,18 +153,19 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
152153

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

156158
if (preferredColorScheme && themeData?.type !== preferredColorScheme && this.storageService.get(PERSISTED_OS_COLOR_SCHEME, PERSISTED_OS_COLOR_SCHEME_SCOPE) !== preferredColorScheme) {
157-
themeData = ColorThemeData.createUnloadedThemeForThemeType(preferredColorScheme);
159+
themeData = ColorThemeData.createUnloadedThemeForThemeType(preferredColorScheme, undefined);
158160
}
159161
if (!themeData) {
160162
const initialColorTheme = environmentService.options?.initialColorTheme;
161163
if (initialColorTheme) {
162-
themeData = ColorThemeData.createUnloadedThemeForThemeType(initialColorTheme.themeType, initialColorTheme.colors);
164+
themeData = ColorThemeData.createUnloadedThemeForThemeType(initialColorTheme.themeType, initialColorTheme.colors ?? defaultColorMap);
163165
}
164166
}
165167
if (!themeData) {
166-
themeData = ColorThemeData.createUnloadedThemeForThemeType(isWeb ? ColorScheme.LIGHT : ColorScheme.DARK);
168+
themeData = ColorThemeData.createUnloadedThemeForThemeType(isWeb ? ColorScheme.LIGHT : ColorScheme.DARK, defaultColorMap);
167169
}
168170
themeData.setCustomizations(this.settings);
169171
this.applyTheme(themeData, undefined, true);

src/vs/workbench/services/themes/common/colorThemeData.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -587,22 +587,6 @@ export class ColorThemeData implements IWorkbenchColorTheme {
587587
// constructors
588588

589589
static createUnloadedThemeForThemeType(themeType: ColorScheme, colorMap?: { [id: string]: string }): ColorThemeData {
590-
if (!colorMap) {
591-
if (themeType === ColorScheme.LIGHT) {
592-
colorMap = {
593-
'activityBar.background': '#f8f8f8',
594-
'statusBar.background': '#f8f8f8',
595-
'statusBar.noFolderBackground': '#f8f8f8'
596-
};
597-
} else {
598-
colorMap = {
599-
'activityBar.background': '#181818',
600-
'statusBar.background': '#181818',
601-
'statusBar.noFolderBackground': '#1f1f1f',
602-
};
603-
}
604-
605-
}
606590
return ColorThemeData.createUnloadedTheme(getThemeTypeSelector(themeType), colorMap);
607591
}
608592

src/vs/workbench/services/themes/common/workbenchThemeService.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,21 @@ export enum ThemeSettingDefaults {
5050
COLOR_THEME_LIGHT_OLD = 'Default Light+',
5151

5252
FILE_ICON_THEME = 'vs-seti',
53-
PRODUCT_ICON_THEME = 'Default'
53+
PRODUCT_ICON_THEME = 'Default',
5454
}
5555

56+
export const COLOR_THEME_DARK_INITIAL_COLORS = {
57+
'activityBar.background': '#181818',
58+
'statusBar.background': '#181818',
59+
'statusBar.noFolderBackground': '#1f1f1f',
60+
};
61+
62+
export const COLOR_THEME_LIGHT_INITIAL_COLORS = {
63+
'activityBar.background': '#f8f8f8',
64+
'statusBar.background': '#f8f8f8',
65+
'statusBar.noFolderBackground': '#f8f8f8'
66+
};
67+
5668
export interface IWorkbenchTheme {
5769
readonly id: string;
5870
readonly label: string;

0 commit comments

Comments
 (0)