提交 14b7df48 编写于 作者: M Martin Aeschlimann

do not restore default theme

上级 4d019515
......@@ -139,7 +139,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
// In order to avoid paint flashing for tokens, because
// 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);
let themeData: ColorThemeData | undefined = ColorThemeData.fromStorageData(this.storageService, isWeb);
// the preferred color scheme (high contrast, light, dark) has changed since the last start
const preferredColorScheme = this.getPreferredColorScheme();
......@@ -496,7 +496,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
// remember theme data for a quick restore
if (newTheme.isLoaded) {
newTheme.toStorage(this.storageService);
newTheme.toStorage(this.storageService, this.settings.isDefaultColorTheme(newTheme));
}
return this.settings.setColorTheme(this.currentColorTheme, settingsTarget);
......
......@@ -505,7 +505,7 @@ export class ColorThemeData implements IWorkbenchColorTheme {
this.customTokenScopeMatchers = undefined;
}
toStorage(storageService: IStorageService) {
toStorage(storageService: IStorageService, isDefaultTheme: boolean) {
let colorMapData: { [key: string]: string } = {};
for (let key in this.colorMap) {
colorMapData[key] = Color.Format.CSS.formatHexA(this.colorMap[key], true);
......@@ -515,12 +515,13 @@ export class ColorThemeData implements IWorkbenchColorTheme {
id: this.id,
label: this.label,
settingsId: this.settingsId,
themeTokenColors: this.themeTokenColors.map(tc => ({ settings: tc.settings, scope: tc.scope })), // don't pesist names
themeTokenColors: this.themeTokenColors.map(tc => ({ settings: tc.settings, scope: tc.scope })), // don't persist names
semanticTokenRules: this.semanticTokenRules.map(SemanticTokenRule.toJSONObject),
extensionData: ExtensionData.toJSONObject(this.extensionData),
themeSemanticHighlighting: this.themeSemanticHighlighting,
colorMap: colorMapData,
watch: this.watch
watch: this.watch,
isDefaultTheme
});
// roam persisted color theme colors. Don't enable for icons as they contain references to fonts and images.
......@@ -570,12 +571,14 @@ export class ColorThemeData implements IWorkbenchColorTheme {
return themeData;
}
static fromStorageData(storageService: IStorageService): ColorThemeData | undefined {
static fromStorageData(storageService: IStorageService, doNotRestoreDefaultTheme: boolean): ColorThemeData | undefined {
const input = storageService.get(ColorThemeData.STORAGE_KEY, StorageScope.GLOBAL);
if (!input) {
return undefined;
}
try {
let isDefaultTheme = false;
let data = JSON.parse(input);
let theme = new ColorThemeData('', '', '');
for (let key in data) {
......@@ -607,9 +610,12 @@ export class ColorThemeData implements IWorkbenchColorTheme {
case 'extensionData':
theme.extensionData = ExtensionData.fromJSONObject(data.extensionData);
break;
case 'isDefaultTheme':
isDefaultTheme = data.isDefaultTheme;
break;
}
}
if (!theme.id || !theme.settingsId) {
if (!theme.id || !theme.settingsId || doNotRestoreDefaultTheme && isDefaultTheme) {
return undefined;
}
return theme;
......
......@@ -308,6 +308,11 @@ export class ThemeConfiguration {
return theme;
}
public isDefaultColorTheme(theme: IWorkbenchColorTheme): boolean {
let settings = this.configurationService.inspect(ThemeSettings.COLOR_THEME);
return settings && settings.default?.value === theme.settingsId;
}
public findAutoConfigurationTarget(key: string) {
let settings = this.configurationService.inspect(key);
if (!types.isUndefined(settings.workspaceFolderValue)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册