@@ -242,24 +242,22 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
242
242
}
243
243
const workspaces = new ResourceMap < IUserDataProfile > ( ) ;
244
244
const emptyWindows = new Map < string , IUserDataProfile > ( ) ;
245
- const defaultProfile = toUserDataProfile ( hash ( this . environmentService . userRoamingDataHome . path ) . toString ( 16 ) , localize ( 'defaultProfile' , "Default" ) , this . environmentService . userRoamingDataHome ) ;
245
+ const defaultProfile = this . createDefaultProfile ( ) ;
246
246
profiles . unshift ( { ...defaultProfile , extensionsResource : this . getDefaultProfileExtensionsLocation ( ) ?? defaultProfile . extensionsResource , isDefault : true } ) ;
247
247
if ( profiles . length ) {
248
248
const profileAssociaitions = this . getStoredProfileAssociations ( ) ;
249
249
if ( profileAssociaitions . workspaces ) {
250
- for ( const [ workspacePath , profilePath ] of Object . entries ( profileAssociaitions . workspaces ) ) {
250
+ for ( const [ workspacePath , profileId ] of Object . entries ( profileAssociaitions . workspaces ) ) {
251
251
const workspace = URI . parse ( workspacePath ) ;
252
- const profileLocation = URI . parse ( profilePath ) ;
253
- const profile = profiles . find ( p => this . uriIdentityService . extUri . isEqual ( p . location , profileLocation ) ) ;
252
+ const profile = profiles . find ( p => p . id === profileId ) ;
254
253
if ( profile ) {
255
254
workspaces . set ( workspace , profile ) ;
256
255
}
257
256
}
258
257
}
259
258
if ( profileAssociaitions . emptyWindows ) {
260
- for ( const [ windowId , profilePath ] of Object . entries ( profileAssociaitions . emptyWindows ) ) {
261
- const profileLocation = URI . parse ( profilePath ) ;
262
- const profile = profiles . find ( p => this . uriIdentityService . extUri . isEqual ( p . location , profileLocation ) ) ;
259
+ for ( const [ windowId , profileId ] of Object . entries ( profileAssociaitions . emptyWindows ) ) {
260
+ const profile = profiles . find ( p => p . id === profileId ) ;
263
261
if ( profile ) {
264
262
emptyWindows . set ( windowId , profile ) ;
265
263
}
@@ -271,6 +269,10 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
271
269
return this . _profilesObject ;
272
270
}
273
271
272
+ private createDefaultProfile ( ) {
273
+ return toUserDataProfile ( '__default__profile__' , localize ( 'defaultProfile' , "Default" ) , this . environmentService . userRoamingDataHome ) ;
274
+ }
275
+
274
276
async createTransientProfile ( workspaceIdentifier ?: IAnyWorkspaceIdentifier ) : Promise < IUserDataProfile > {
275
277
const namePrefix = `Temp` ;
276
278
const nameRegEx = new RegExp ( `${ escapeRegExpCharacters ( namePrefix ) } \\s(\\d+)` ) ;
@@ -548,16 +550,36 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
548
550
private updateStoredProfileAssociations ( ) {
549
551
const workspaces : IStringDictionary < string > = { } ;
550
552
for ( const [ workspace , profile ] of this . profilesObject . workspaces . entries ( ) ) {
551
- workspaces [ workspace . toString ( ) ] = profile . location . toString ( ) ;
553
+ workspaces [ workspace . toString ( ) ] = profile . id ;
552
554
}
553
555
const emptyWindows : IStringDictionary < string > = { } ;
554
556
for ( const [ windowId , profile ] of this . profilesObject . emptyWindows . entries ( ) ) {
555
- emptyWindows [ windowId . toString ( ) ] = profile . location . toString ( ) ;
557
+ emptyWindows [ windowId . toString ( ) ] = profile . id ;
556
558
}
557
559
this . saveStoredProfileAssociations ( { workspaces, emptyWindows } ) ;
558
560
this . _profilesObject = undefined ;
559
561
}
560
562
563
+ // TODO: @sandy 081 Remove migration after couple of releases
564
+ protected migrateStoredProfileAssociations ( storedProfileAssociations : StoredProfileAssociations ) : StoredProfileAssociations {
565
+ const workspaces : IStringDictionary < string > = { } ;
566
+ const defaultProfile = this . createDefaultProfile ( ) ;
567
+ if ( storedProfileAssociations . workspaces ) {
568
+ for ( const [ workspace , location ] of Object . entries ( storedProfileAssociations . workspaces ) ) {
569
+ const uri = URI . parse ( location ) ;
570
+ workspaces [ workspace ] = this . uriIdentityService . extUri . isEqual ( uri , defaultProfile . location ) ? defaultProfile . id : this . uriIdentityService . extUri . basename ( uri ) ;
571
+ }
572
+ }
573
+ const emptyWindows : IStringDictionary < string > = { } ;
574
+ if ( storedProfileAssociations . emptyWindows ) {
575
+ for ( const [ workspace , location ] of Object . entries ( storedProfileAssociations . emptyWindows ) ) {
576
+ const uri = URI . parse ( location ) ;
577
+ emptyWindows [ workspace ] = this . uriIdentityService . extUri . isEqual ( uri , defaultProfile . location ) ? defaultProfile . id : this . uriIdentityService . extUri . basename ( uri ) ;
578
+ }
579
+ }
580
+ return { workspaces, emptyWindows } ;
581
+ }
582
+
561
583
protected getStoredProfiles ( ) : StoredUserDataProfile [ ] { return [ ] ; }
562
584
protected saveStoredProfiles ( storedProfiles : StoredUserDataProfile [ ] ) : void { throw new Error ( 'not implemented' ) ; }
563
585
0 commit comments