Skip to content

Commit 138c96b

Browse files
authored
1 parent 0689b19 commit 138c96b

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

src/vs/platform/extensionManagement/electron-main/defaultExtensionsProfileInit.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { URI } from 'vs/base/common/uri';
99
import { IExtensionsProfileScannerService } from 'vs/platform/extensionManagement/common/extensionsProfileScannerService';
1010
import { IExtensionsScannerService } from 'vs/platform/extensionManagement/common/extensionsScannerService';
1111
import { IFileService } from 'vs/platform/files/common/files';
12+
import { ILogService } from 'vs/platform/log/common/log';
1213
import { EXTENSIONS_RESOURCE_NAME } from 'vs/platform/userDataProfile/common/userDataProfile';
1314
import { IUserDataProfilesMainService } from 'vs/platform/userDataProfile/electron-main/userDataProfile';
1415

@@ -18,18 +19,23 @@ export class DefaultExtensionsProfileInitHandler extends Disposable {
1819
@IFileService private readonly fileService: IFileService,
1920
@IExtensionsScannerService private readonly extensionsScannerService: IExtensionsScannerService,
2021
@IExtensionsProfileScannerService private readonly extensionsProfileScannerService: IExtensionsProfileScannerService,
22+
@ILogService logService: ILogService,
2123
) {
2224
super();
23-
this._register(userDataProfilesService.onWillCreateProfile(e => {
24-
if (userDataProfilesService.profiles.length === 1) {
25-
e.join(this.initialize());
26-
}
27-
}));
28-
this._register(userDataProfilesService.onDidChangeProfiles(e => {
29-
if (userDataProfilesService.profiles.length === 1) {
30-
this.uninitialize();
31-
}
32-
}));
25+
if (userDataProfilesService.isEnabled()) {
26+
this._register(userDataProfilesService.onWillCreateProfile(e => {
27+
if (userDataProfilesService.profiles.length === 1) {
28+
e.join(this.initialize());
29+
}
30+
}));
31+
this._register(userDataProfilesService.onDidChangeProfiles(e => {
32+
if (userDataProfilesService.profiles.length === 1) {
33+
this.uninitialize();
34+
}
35+
}));
36+
} else {
37+
this.uninitialize().then(null, e => logService.error(e));
38+
}
3339
}
3440

3541
private async initialize(): Promise<void> {

src/vs/platform/userDataProfile/electron-main/userDataProfile.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ export class UserDataProfilesMainService extends UserDataProfilesService impleme
3939
super(stateMainService, uriIdentityService, environmentService, fileService, logService);
4040
}
4141

42+
override setEnablement(enabled: boolean): void {
43+
super.setEnablement(enabled);
44+
if (!this.enabled) {
45+
// reset
46+
this.saveStoredProfiles([]);
47+
this.saveStoredProfileAssociations({});
48+
}
49+
}
50+
4251
isEnabled(): boolean {
4352
return this.enabled;
4453
}
@@ -69,11 +78,19 @@ export class UserDataProfilesMainService extends UserDataProfilesService impleme
6978
}
7079

7180
protected override saveStoredProfiles(storedProfiles: StoredUserDataProfile[]): void {
72-
this.stateMainService.setItem(UserDataProfilesMainService.PROFILES_KEY, storedProfiles);
81+
if (storedProfiles.length) {
82+
this.stateMainService.setItem(UserDataProfilesMainService.PROFILES_KEY, storedProfiles);
83+
} else {
84+
this.stateMainService.removeItem(UserDataProfilesMainService.PROFILES_KEY);
85+
}
7386
}
7487

7588
protected override saveStoredProfileAssociations(storedProfileAssociations: StoredProfileAssociations): void {
76-
this.stateMainService.setItem(UserDataProfilesMainService.PROFILE_ASSOCIATIONS_KEY, storedProfileAssociations);
89+
if (storedProfileAssociations.emptyWindow || storedProfileAssociations.workspaces) {
90+
this.stateMainService.setItem(UserDataProfilesMainService.PROFILE_ASSOCIATIONS_KEY, storedProfileAssociations);
91+
} else {
92+
this.stateMainService.removeItem(UserDataProfilesMainService.PROFILE_ASSOCIATIONS_KEY);
93+
}
7794
}
7895

7996
protected override getStoredProfileAssociations(): StoredProfileAssociations {

0 commit comments

Comments
 (0)