@@ -242,24 +242,22 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
242242 }
243243 const workspaces = new ResourceMap < IUserDataProfile > ( ) ;
244244 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 ( ) ;
246246 profiles . unshift ( { ...defaultProfile , extensionsResource : this . getDefaultProfileExtensionsLocation ( ) ?? defaultProfile . extensionsResource , isDefault : true } ) ;
247247 if ( profiles . length ) {
248248 const profileAssociaitions = this . getStoredProfileAssociations ( ) ;
249249 if ( profileAssociaitions . workspaces ) {
250- for ( const [ workspacePath , profilePath ] of Object . entries ( profileAssociaitions . workspaces ) ) {
250+ for ( const [ workspacePath , profileId ] of Object . entries ( profileAssociaitions . workspaces ) ) {
251251 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 ) ;
254253 if ( profile ) {
255254 workspaces . set ( workspace , profile ) ;
256255 }
257256 }
258257 }
259258 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 ) ;
263261 if ( profile ) {
264262 emptyWindows . set ( windowId , profile ) ;
265263 }
@@ -271,6 +269,10 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
271269 return this . _profilesObject ;
272270 }
273271
272+ private createDefaultProfile ( ) {
273+ return toUserDataProfile ( '__default__profile__' , localize ( 'defaultProfile' , "Default" ) , this . environmentService . userRoamingDataHome ) ;
274+ }
275+
274276 async createTransientProfile ( workspaceIdentifier ?: IAnyWorkspaceIdentifier ) : Promise < IUserDataProfile > {
275277 const namePrefix = `Temp` ;
276278 const nameRegEx = new RegExp ( `${ escapeRegExpCharacters ( namePrefix ) } \\s(\\d+)` ) ;
@@ -548,16 +550,36 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
548550 private updateStoredProfileAssociations ( ) {
549551 const workspaces : IStringDictionary < string > = { } ;
550552 for ( const [ workspace , profile ] of this . profilesObject . workspaces . entries ( ) ) {
551- workspaces [ workspace . toString ( ) ] = profile . location . toString ( ) ;
553+ workspaces [ workspace . toString ( ) ] = profile . id ;
552554 }
553555 const emptyWindows : IStringDictionary < string > = { } ;
554556 for ( const [ windowId , profile ] of this . profilesObject . emptyWindows . entries ( ) ) {
555- emptyWindows [ windowId . toString ( ) ] = profile . location . toString ( ) ;
557+ emptyWindows [ windowId . toString ( ) ] = profile . id ;
556558 }
557559 this . saveStoredProfileAssociations ( { workspaces, emptyWindows } ) ;
558560 this . _profilesObject = undefined ;
559561 }
560562
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+
561583 protected getStoredProfiles ( ) : StoredUserDataProfile [ ] { return [ ] ; }
562584 protected saveStoredProfiles ( storedProfiles : StoredUserDataProfile [ ] ) : void { throw new Error ( 'not implemented' ) ; }
563585
0 commit comments