@@ -13,13 +13,13 @@ import { getZoomLevel } from 'vs/base/browser/browser';
1313import { mark } from 'vs/base/common/performance' ;
1414import { onUnexpectedError , setUnexpectedErrorHandler } from 'vs/base/common/errors' ;
1515import { Registry } from 'vs/platform/registry/common/platform' ;
16- import { isWindows , isLinux , isWeb } from 'vs/base/common/platform' ;
16+ import { isWindows , isLinux , isWeb , isNative } from 'vs/base/common/platform' ;
1717import { IWorkbenchContributionsRegistry , Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions' ;
1818import { IEditorInputFactoryRegistry , Extensions as EditorExtensions } from 'vs/workbench/common/editor' ;
1919import { IActionBarRegistry , Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions' ;
2020import { getServices } from 'vs/platform/instantiation/common/extensions' ;
2121import { Position , Parts , IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService' ;
22- import { IStorageService } from 'vs/platform/storage/common/storage' ;
22+ import { IStorageService , WillSaveStateReason , StorageScope } from 'vs/platform/storage/common/storage' ;
2323import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
2424import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet' ;
2525import { IPanelService } from 'vs/workbench/services/panel/common/panelService' ;
@@ -36,7 +36,7 @@ import { NotificationsToasts } from 'vs/workbench/browser/parts/notifications/no
3636import { IEditorService , IResourceEditor } from 'vs/workbench/services/editor/common/editorService' ;
3737import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
3838import { setARIAContainer } from 'vs/base/browser/ui/aria/aria' ;
39- import { restoreFontInfo , readFontInfo , saveFontInfo } from 'vs/editor/browser/config/configuration' ;
39+ import { readFontInfo , restoreFontInfo , serializeFontInfo } from 'vs/editor/browser/config/configuration' ;
4040import { BareFontInfo } from 'vs/editor/common/config/fontInfo' ;
4141import { ILogService } from 'vs/platform/log/common/log' ;
4242import { toErrorMessage } from 'vs/base/common/errorMessage' ;
@@ -217,9 +217,6 @@ export class Workbench extends Layout {
217217 this . dispose ( ) ;
218218 } ) ) ;
219219
220- // Storage
221- this . _register ( storageService . onWillSaveState ( ( ) => saveFontInfo ( storageService ) ) ) ;
222-
223220 // Configuration changes
224221 this . _register ( configurationService . onDidChangeConfiguration ( ( ) => this . setFontAliasing ( configurationService ) ) ) ;
225222 }
@@ -243,6 +240,37 @@ export class Workbench extends Layout {
243240 }
244241 }
245242
243+ private warmUpFontCache ( storageService : IStorageService , configurationService : IConfigurationService ) : void {
244+ const key = 'editorFontInfo' ;
245+
246+ // Restore (native: use storage service, web: use browser specific local storage)
247+ const storedFontInfoRaw = isNative ? storageService . get ( key , StorageScope . GLOBAL ) : window . localStorage . getItem ( key ) ;
248+ if ( storedFontInfoRaw ) {
249+ try {
250+ const storedFontInfo = JSON . parse ( storedFontInfoRaw ) ;
251+ if ( Array . isArray ( storedFontInfo ) ) {
252+ restoreFontInfo ( storedFontInfo ) ;
253+ }
254+ } catch ( err ) {
255+ /* ignore */
256+ }
257+ }
258+
259+ readFontInfo ( BareFontInfo . createFromRawSettings ( configurationService . getValue ( 'editor' ) , getZoomLevel ( ) ) ) ;
260+
261+ // Persist on shutdown (native: use storage service, web: use browser specific local storage)
262+ this . _register ( storageService . onWillSaveState ( e => {
263+ if ( e . reason === WillSaveStateReason . SHUTDOWN ) {
264+ const serializedFontInfo = serializeFontInfo ( ) ;
265+ if ( serializedFontInfo ) {
266+ const serializedFontInfoRaw = JSON . stringify ( serializedFontInfo ) ;
267+
268+ isNative ? storageService . store ( key , serializedFontInfoRaw , StorageScope . GLOBAL ) : window . localStorage . setItem ( key , serializedFontInfoRaw ) ;
269+ }
270+ }
271+ } ) ) ;
272+ }
273+
246274 private renderWorkbench ( instantiationService : IInstantiationService , notificationService : NotificationService , storageService : IStorageService , configurationService : IConfigurationService ) : void {
247275
248276 // State specific classes
@@ -268,8 +296,7 @@ export class Workbench extends Layout {
268296 this . setFontAliasing ( configurationService ) ;
269297
270298 // Warm up font cache information before building up too many dom elements
271- restoreFontInfo ( storageService ) ;
272- readFontInfo ( BareFontInfo . createFromRawSettings ( configurationService . getValue ( 'editor' ) , getZoomLevel ( ) ) ) ;
299+ this . warmUpFontCache ( storageService , configurationService ) ;
273300
274301 // Create Parts
275302 [
0 commit comments