@@ -14,6 +14,7 @@ import { IStorage, IStorageDatabase, IUpdateRequest, Storage } from 'vs/base/par
1414import { URI } from 'vs/base/common/uri' ;
1515import { VSBuffer } from 'vs/base/common/buffer' ;
1616import { joinPath } from 'vs/base/common/resources' ;
17+ import { serializableToMap , mapToSerializable } from 'vs/base/common/map' ;
1718
1819export class BrowserStorageService extends Disposable implements IStorageService {
1920
@@ -51,12 +52,12 @@ export class BrowserStorageService extends Disposable implements IStorageService
5152 private async doInitialize ( payload : IWorkspaceInitializationPayload ) : Promise < void > {
5253
5354 // Workspace Storage
54- this . workspaceStorageFile = joinPath ( this . environmentService . userRoamingDataHome , 'workspaceStorage ' , `${ payload . id } .json` ) ;
55+ this . workspaceStorageFile = joinPath ( this . environmentService . userRoamingDataHome , 'state ' , `${ payload . id } .json` ) ;
5556 this . workspaceStorage = new Storage ( this . _register ( new FileStorageDatabase ( this . workspaceStorageFile , this . fileService ) ) ) ;
5657 this . _register ( this . workspaceStorage . onDidChangeStorage ( key => this . _onDidChangeStorage . fire ( { key, scope : StorageScope . WORKSPACE } ) ) ) ;
5758
5859 // Global Storage
59- this . globalStorageFile = joinPath ( this . environmentService . userRoamingDataHome , 'globalStorage ' , 'global.json' ) ;
60+ this . globalStorageFile = joinPath ( this . environmentService . userRoamingDataHome , 'state ' , 'global.json' ) ;
6061 this . globalStorage = new Storage ( this . _register ( new FileStorageDatabase ( this . globalStorageFile , this . fileService ) ) ) ;
6162 this . _register ( this . globalStorage . onDidChangeStorage ( key => this . _onDidChangeStorage . fire ( { key, scope : StorageScope . GLOBAL } ) ) ) ;
6263
@@ -166,7 +167,7 @@ export class FileStorageDatabase extends Disposable implements IStorageDatabase
166167
167168 const itemsRaw = await this . fileService . readFile ( this . file ) ;
168169
169- return new Map ( JSON . parse ( itemsRaw . value . toString ( ) ) ) ;
170+ return serializableToMap ( JSON . parse ( itemsRaw . value . toString ( ) ) ) ;
170171 }
171172
172173 async updateItems ( request : IUpdateRequest ) : Promise < void > {
@@ -192,11 +193,9 @@ export class FileStorageDatabase extends Disposable implements IStorageDatabase
192193 request . delete . forEach ( key => items . delete ( key ) ) ;
193194 }
194195
195- const itemsRaw = JSON . stringify ( [ ...items ] ) ;
196-
197196 await this . pendingUpdate ;
198197
199- this . pendingUpdate = this . fileService . writeFile ( this . file , VSBuffer . fromString ( itemsRaw ) ) . then ( ) ;
198+ this . pendingUpdate = this . fileService . writeFile ( this . file , VSBuffer . fromString ( JSON . stringify ( mapToSerializable ( items ) ) ) ) . then ( ) ;
200199
201200 return this . pendingUpdate ;
202201 }
0 commit comments