Skip to content

Commit 73ce0a4

Browse files
committed
Workbench Appearance color theme keeps being overridden. Fixes microsoft#105102
1 parent 63ea73a commit 73ce0a4

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

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

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
132132

133133
// the preferred color scheme (high contrast, light, dark) has changed since the last start
134134
const preferredColorScheme = this.getPreferredColorScheme();
135-
if (preferredColorScheme && themeData?.baseTheme !== preferredColorScheme && this.storageService.get(PERSISTED_OS_COLOR_SCHEME, StorageScope.GLOBAL) !== preferredColorScheme) {
135+
136+
if (preferredColorScheme && themeData?.type !== preferredColorScheme && this.storageService.get(PERSISTED_OS_COLOR_SCHEME, StorageScope.GLOBAL) !== preferredColorScheme) {
136137
themeData = ColorThemeData.createUnloadedThemeForThemeType(preferredColorScheme);
137138
}
138139
if (!themeData) {
@@ -176,8 +177,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
176177
const theme = await this.colorThemeRegistry.findThemeBySettingsId(this.settings.colorTheme, DEFAULT_COLOR_THEME_ID);
177178

178179
const preferredColorScheme = this.getPreferredColorScheme();
179-
if (preferredColorScheme && theme?.type !== preferredColorScheme) {
180-
return this.applyPreferredColorTheme(preferredColorScheme);
180+
const prevScheme = this.storageService.get(PERSISTED_OS_COLOR_SCHEME, StorageScope.GLOBAL);
181+
if (preferredColorScheme !== prevScheme) {
182+
this.storageService.store(PERSISTED_OS_COLOR_SCHEME, preferredColorScheme, StorageScope.GLOBAL);
183+
if (preferredColorScheme && theme?.type !== preferredColorScheme) {
184+
return this.applyPreferredColorTheme(preferredColorScheme);
185+
}
181186
}
182187
return this.setColorTheme(theme && theme.id, undefined);
183188
};
@@ -331,20 +336,21 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
331336

332337
private async handlePreferredSchemeUpdated() {
333338
const scheme = this.getPreferredColorScheme();
334-
335339
const prevScheme = this.storageService.get(PERSISTED_OS_COLOR_SCHEME, StorageScope.GLOBAL);
336-
this.storageService.store(PERSISTED_OS_COLOR_SCHEME, scheme, StorageScope.GLOBAL);
337-
if (scheme) {
338-
if (!prevScheme) {
339-
// remember the theme before scheme switching
340-
this.themeSettingIdBeforeSchemeSwitch = this.settings.colorTheme;
341-
}
342-
return this.applyPreferredColorTheme(scheme);
343-
} else if (prevScheme && this.themeSettingIdBeforeSchemeSwitch) {
344-
// reapply the theme before scheme switching
345-
const theme = await this.colorThemeRegistry.findThemeBySettingsId(this.themeSettingIdBeforeSchemeSwitch, undefined);
346-
if (theme) {
347-
this.setColorTheme(theme.id, 'auto');
340+
if (scheme !== prevScheme) {
341+
this.storageService.store(PERSISTED_OS_COLOR_SCHEME, scheme, StorageScope.GLOBAL);
342+
if (scheme) {
343+
if (!prevScheme) {
344+
// remember the theme before scheme switching
345+
this.themeSettingIdBeforeSchemeSwitch = this.settings.colorTheme;
346+
}
347+
return this.applyPreferredColorTheme(scheme);
348+
} else if (prevScheme && this.themeSettingIdBeforeSchemeSwitch) {
349+
// reapply the theme before scheme switching
350+
const theme = await this.colorThemeRegistry.findThemeBySettingsId(this.themeSettingIdBeforeSchemeSwitch, undefined);
351+
if (theme) {
352+
this.setColorTheme(theme.id, 'auto');
353+
}
348354
}
349355
}
350356
return undefined;
@@ -371,7 +377,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
371377
if (themeSettingId) {
372378
const theme = await this.colorThemeRegistry.findThemeBySettingsId(themeSettingId, undefined);
373379
if (theme) {
374-
return this.setColorTheme(theme.id, 'auto');
380+
return this.setColorTheme(theme.id, ConfigurationTarget.USER);
375381
}
376382
}
377383
return null;

0 commit comments

Comments
 (0)