diff options
Diffstat (limited to 'src/vs/workbench/services/themes/browser/productIconThemeData.ts')
-rw-r--r-- | src/vs/workbench/services/themes/browser/productIconThemeData.ts | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/vs/workbench/services/themes/browser/productIconThemeData.ts b/src/vs/workbench/services/themes/browser/productIconThemeData.ts index 80a9e6d973b..63ca74a35cd 100644 --- a/src/vs/workbench/services/themes/browser/productIconThemeData.ts +++ b/src/vs/workbench/services/themes/browser/productIconThemeData.ts @@ -13,7 +13,7 @@ import { getParseErrorMessage } from 'vs/base/common/jsonErrorMessages'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { DEFAULT_PRODUCT_ICON_THEME_SETTING_VALUE } from 'vs/workbench/services/themes/common/themeConfiguration'; import { fontIdRegex, fontWeightRegex, fontStyleRegex, fontFormatRegex } from 'vs/workbench/services/themes/common/productIconThemeSchema'; -import { isString } from 'vs/base/common/types'; +import { isObject, isString } from 'vs/base/common/types'; import { ILogService } from 'vs/platform/log/common/log'; import { IconDefinition, getIconRegistry, IconContribution, IconFontDefinition, IconFontSource } from 'vs/platform/theme/common/iconRegistry'; import { ThemeIcon } from 'vs/platform/theme/common/themeService'; @@ -132,6 +132,24 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme { break; } } + const { iconDefinitions, iconFontDefinitions } = data; + if (Array.isArray(iconDefinitions) && isObject(iconFontDefinitions)) { + const restoredIconDefinitions = new Map<string, IconDefinition>(); + for (const entry of iconDefinitions) { + const { id, fontCharacter, fontId } = entry; + if (isString(id) && isString(fontCharacter)) { + if (isString(fontId)) { + const iconFontDefinition = IconFontDefinition.fromJSONObject(iconFontDefinitions[fontId]); + if (iconFontDefinition) { + restoredIconDefinitions.set(id, { fontCharacter, font: { id: fontId, definition: iconFontDefinition } }); + } + } else { + restoredIconDefinitions.set(id, { fontCharacter }); + } + } + } + theme.iconThemeDocument = { iconDefinitions: restoredIconDefinitions }; + } return theme; } catch (e) { return undefined; @@ -139,6 +157,15 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme { } toStorage(storageService: IStorageService) { + const iconDefinitions = []; + const iconFontDefinitions: { [id: string]: IconFontDefinition } = {}; + for (const entry of this.iconThemeDocument.iconDefinitions.entries()) { + const font = entry[1].font; + iconDefinitions.push({ id: entry[0], fontCharacter: entry[1].fontCharacter, fontId: font?.id }); + if (font && iconFontDefinitions[font.id] === undefined) { + iconFontDefinitions[font.id] = IconFontDefinition.toJSONObject(font.definition); + } + } const data = JSON.stringify({ id: this.id, label: this.label, @@ -147,6 +174,8 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme { styleSheetContent: this.styleSheetContent, watch: this.watch, extensionData: ExtensionData.toJSONObject(this.extensionData), + iconDefinitions, + iconFontDefinitions }); storageService.store(ProductIconThemeData.STORAGE_KEY, data, StorageScope.PROFILE, StorageTarget.MACHINE); } |