@@ -13,7 +13,7 @@ import { getParseErrorMessage } from 'vs/base/common/jsonErrorMessages';
13
13
import { IStorageService , StorageScope , StorageTarget } from 'vs/platform/storage/common/storage' ;
14
14
import { DEFAULT_PRODUCT_ICON_THEME_SETTING_VALUE } from 'vs/workbench/services/themes/common/themeConfiguration' ;
15
15
import { fontIdRegex , fontWeightRegex , fontStyleRegex , fontFormatRegex } from 'vs/workbench/services/themes/common/productIconThemeSchema' ;
16
- import { isString } from 'vs/base/common/types' ;
16
+ import { isObject , isString } from 'vs/base/common/types' ;
17
17
import { ILogService } from 'vs/platform/log/common/log' ;
18
18
import { IconDefinition , getIconRegistry , IconContribution , IconFontDefinition , IconFontSource } from 'vs/platform/theme/common/iconRegistry' ;
19
19
import { ThemeIcon } from 'vs/platform/theme/common/themeService' ;
@@ -132,13 +132,40 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme {
132
132
break ;
133
133
}
134
134
}
135
+ const { iconDefinitions, iconFontDefinitions } = data ;
136
+ if ( Array . isArray ( iconDefinitions ) && isObject ( iconFontDefinitions ) ) {
137
+ const restoredIconDefinitions = new Map < string , IconDefinition > ( ) ;
138
+ for ( const entry of iconDefinitions ) {
139
+ const { id, fontCharacter, fontId } = entry ;
140
+ if ( isString ( id ) && isString ( fontCharacter ) ) {
141
+ if ( isString ( fontId ) ) {
142
+ const iconFontDefinition = IconFontDefinition . fromJSONObject ( iconFontDefinitions [ fontId ] ) ;
143
+ if ( iconFontDefinition ) {
144
+ restoredIconDefinitions . set ( id , { fontCharacter, font : { id : fontId , definition : iconFontDefinition } } ) ;
145
+ }
146
+ } else {
147
+ restoredIconDefinitions . set ( id , { fontCharacter } ) ;
148
+ }
149
+ }
150
+ }
151
+ theme . iconThemeDocument = { iconDefinitions : restoredIconDefinitions } ;
152
+ }
135
153
return theme ;
136
154
} catch ( e ) {
137
155
return undefined ;
138
156
}
139
157
}
140
158
141
159
toStorage ( storageService : IStorageService ) {
160
+ const iconDefinitions = [ ] ;
161
+ const iconFontDefinitions : { [ id : string ] : IconFontDefinition } = { } ;
162
+ for ( const entry of this . iconThemeDocument . iconDefinitions . entries ( ) ) {
163
+ const font = entry [ 1 ] . font ;
164
+ iconDefinitions . push ( { id : entry [ 0 ] , fontCharacter : entry [ 1 ] . fontCharacter , fontId : font ?. id } ) ;
165
+ if ( font && iconFontDefinitions [ font . id ] === undefined ) {
166
+ iconFontDefinitions [ font . id ] = IconFontDefinition . toJSONObject ( font . definition ) ;
167
+ }
168
+ }
142
169
const data = JSON . stringify ( {
143
170
id : this . id ,
144
171
label : this . label ,
@@ -147,6 +174,8 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme {
147
174
styleSheetContent : this . styleSheetContent ,
148
175
watch : this . watch ,
149
176
extensionData : ExtensionData . toJSONObject ( this . extensionData ) ,
177
+ iconDefinitions,
178
+ iconFontDefinitions
150
179
} ) ;
151
180
storageService . store ( ProductIconThemeData . STORAGE_KEY , data , StorageScope . PROFILE , StorageTarget . MACHINE ) ;
152
181
}
0 commit comments