提交 426214a2 编写于 作者: M Martin Aeschlimann

sync persisted color theme data

上级 114c7eab
......@@ -14,9 +14,10 @@ import { getParseErrorMessage } from 'vs/base/common/jsonErrorMessages';
import { asCSSUrl } from 'vs/base/browser/dom';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
const PERSISTED_FILE_ICON_THEME_STORAGE_KEY = 'iconThemeData';
export class FileIconThemeData implements IWorkbenchFileIconTheme {
static readonly STORAGE_KEY = 'iconThemeData';
id: string;
label: string;
settingsId: string | null;
......@@ -108,7 +109,7 @@ export class FileIconThemeData implements IWorkbenchFileIconTheme {
static fromStorageData(storageService: IStorageService): FileIconThemeData | undefined {
const input = storageService.get(PERSISTED_FILE_ICON_THEME_STORAGE_KEY, StorageScope.GLOBAL);
const input = storageService.get(FileIconThemeData.STORAGE_KEY, StorageScope.GLOBAL);
if (!input) {
return undefined;
}
......@@ -129,7 +130,7 @@ export class FileIconThemeData implements IWorkbenchFileIconTheme {
(theme as any)[key] = data[key];
break;
case 'location':
theme.location = URI.revive(data.location);
// ignore, no longer restore
break;
case 'extensionData':
theme.extensionData = ExtensionData.fromJSONObject(data.extensionData);
......@@ -148,7 +149,6 @@ export class FileIconThemeData implements IWorkbenchFileIconTheme {
label: this.label,
description: this.description,
settingsId: this.settingsId,
location: this.location?.toJSON(),
styleSheetContent: this.styleSheetContent,
hasFileIcons: this.hasFileIcons,
hasFolderIcons: this.hasFolderIcons,
......@@ -156,7 +156,7 @@ export class FileIconThemeData implements IWorkbenchFileIconTheme {
extensionData: ExtensionData.toJSONObject(this.extensionData),
watch: this.watch
});
storageService.store(PERSISTED_FILE_ICON_THEME_STORAGE_KEY, data, StorageScope.GLOBAL);
storageService.store(FileIconThemeData.STORAGE_KEY, data, StorageScope.GLOBAL);
}
}
......
......@@ -20,11 +20,12 @@ import { ILogService } from 'vs/platform/log/common/log';
import { getIconRegistry } from 'vs/platform/theme/common/iconRegistry';
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
const PERSISTED_PRODUCT_ICON_THEME_STORAGE_KEY = 'productIconThemeData';
export const DEFAULT_PRODUCT_ICON_THEME_ID = ''; // TODO
export class ProductIconThemeData implements IWorkbenchProductIconTheme {
static readonly STORAGE_KEY = 'productIconThemeData';
id: string;
label: string;
settingsId: string;
......@@ -104,7 +105,7 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme {
}
static fromStorageData(storageService: IStorageService): ProductIconThemeData | undefined {
const input = storageService.get(PERSISTED_PRODUCT_ICON_THEME_STORAGE_KEY, StorageScope.GLOBAL);
const input = storageService.get(ProductIconThemeData.STORAGE_KEY, StorageScope.GLOBAL);
if (!input) {
return undefined;
}
......@@ -122,7 +123,7 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme {
(theme as any)[key] = data[key];
break;
case 'location':
theme.location = URI.revive(data.location);
// ignore, no longer restore
break;
case 'extensionData':
theme.extensionData = ExtensionData.fromJSONObject(data.extensionData);
......@@ -141,12 +142,11 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme {
label: this.label,
description: this.description,
settingsId: this.settingsId,
location: this.location?.toJSON(),
styleSheetContent: this.styleSheetContent,
watch: this.watch,
extensionData: ExtensionData.toJSONObject(this.extensionData),
});
storageService.store(PERSISTED_PRODUCT_ICON_THEME_STORAGE_KEY, data, StorageScope.GLOBAL);
storageService.store(ProductIconThemeData.STORAGE_KEY, data, StorageScope.GLOBAL);
}
}
......
......@@ -38,6 +38,7 @@ import { ColorScheme } from 'vs/platform/theme/common/theme';
import { IHostColorSchemeService } from 'vs/workbench/services/themes/common/hostColorSchemeService';
import { CodiconStyles } from 'vs/base/browser/ui/codicons/codiconStyles';
import { RunOnceScheduler } from 'vs/base/common/async';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
// implementation
......@@ -108,7 +109,11 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
@IWorkbenchLayoutService readonly layoutService: IWorkbenchLayoutService,
@ILogService private readonly logService: ILogService,
@IHostColorSchemeService private readonly hostColorService: IHostColorSchemeService,
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
) {
// roam persisted color theme colors. Don't enable for icons as they contain references to fonts and images.
storageKeysSyncRegistryService.registerStorageKey({ key: ColorThemeData.STORAGE_KEY, version: 1 });
this.container = layoutService.container;
this.settings = new ThemeConfiguration(configurationService);
......
......@@ -45,10 +45,10 @@ export type TokenStyleDefinitions = { [P in keyof TokenStyleData]?: TokenStyleDe
export type TextMateThemingRuleDefinitions = { [P in keyof TokenStyleData]?: ITextMateThemingRule | undefined; } & { scope?: ProbeScope; };
const PERSISTED_THEME_STORAGE_KEY = 'colorThemeData';
export class ColorThemeData implements IWorkbenchColorTheme {
static readonly STORAGE_KEY = 'colorThemeData';
id: string;
label: string;
settingsId: string;
......@@ -515,14 +515,16 @@ export class ColorThemeData implements IWorkbenchColorTheme {
id: this.id,
label: this.label,
settingsId: this.settingsId,
themeTokenColors: this.themeTokenColors,
themeTokenColors: this.themeTokenColors.map(tc => ({ settings: tc.settings, scope: tc.scope })), // don't pesist names
semanticTokenRules: this.semanticTokenRules.map(SemanticTokenRule.toJSONObject),
extensionData: ExtensionData.toJSONObject(this.extensionData),
themeSemanticHighlighting: this.themeSemanticHighlighting,
colorMap: colorMapData,
watch: this.watch
});
storageService.store(PERSISTED_THEME_STORAGE_KEY, value, StorageScope.GLOBAL);
console.log(`${value.length} + ${value}`);
storageService.store(ColorThemeData.STORAGE_KEY, value, StorageScope.GLOBAL);
}
get baseTheme(): string {
......@@ -569,7 +571,7 @@ export class ColorThemeData implements IWorkbenchColorTheme {
}
static fromStorageData(storageService: IStorageService): ColorThemeData | undefined {
const input = storageService.get(PERSISTED_THEME_STORAGE_KEY, StorageScope.GLOBAL);
const input = storageService.get(ColorThemeData.STORAGE_KEY, StorageScope.GLOBAL);
if (!input) {
return undefined;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册