Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jun 29, 2022
1 parent ab301f9 commit 0d3e7e6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class NativeProfileAwareExtensionManagementService extends ExtensionManag
private readonly _onDidChangeProfileExtensions = this._register(new Emitter<{ readonly added: ILocalExtension[]; readonly removed: ILocalExtension[] }>());
readonly onDidChangeProfileExtensions = this._onDidChangeProfileExtensions.event;

constructor(channel: IChannel, private extensionsProfileResource: URI | undefined,
constructor(channel: IChannel, public extensionsProfileResource: URI | undefined,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
) {
super(channel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
import { NativeProfileAwareExtensionManagementService } from 'vs/workbench/services/extensionManagement/common/profileAwareExtensionManagementService';
import { Disposable } from 'vs/base/common/lifecycle';
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';

export class ExtensionManagementServerService extends Disposable implements IExtensionManagementServerService {

Expand All @@ -30,12 +31,18 @@ export class ExtensionManagementServerService extends Disposable implements IExt
@ISharedProcessService sharedProcessService: ISharedProcessService,
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
@ILabelService labelService: ILabelService,
@IUserDataProfilesService userDataProfilesService: IUserDataProfilesService,
@IUserDataProfileService userDataProfileService: IUserDataProfileService,
@IInstantiationService instantiationService: IInstantiationService,
) {
super();
const localExtensionManagementService = this._register(instantiationService.createInstance(NativeProfileAwareExtensionManagementService, sharedProcessService.getChannel('extensions'), userDataProfileService.currentProfile.extensionsResource));
this.localExtensionManagementServer = { extensionManagementService: localExtensionManagementService, id: 'local', label: localize('local', "Local") };
this._register(userDataProfilesService.onDidChangeProfiles(e => {
if (userDataProfileService.currentProfile.isDefault) {
localExtensionManagementService.extensionsProfileResource = userDataProfilesService.defaultProfile.extensionsResource;
}
}));
this._register(userDataProfileService.onDidChangeCurrentProfile(e => e.join(localExtensionManagementService.switchExtensionsProfile(e.profile.extensionsResource))));
const remoteAgentConnection = remoteAgentService.getConnection();
if (remoteAgentConnection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export class UserDataProfileManagementService extends Disposable implements IUse
private onDidChangeProfiles(e: DidChangeProfilesEvent): void {
if (e.removed.some(profile => profile.id === this.userDataProfileService.currentProfile.id)) {
this.enterProfile(this.userDataProfilesService.defaultProfile, false, localize('reload message when removed', "The current profile has been removed. Please reload to switch back to default profile"));
return;
}
if (this.userDataProfileService.currentProfile.isDefault) {
this.userDataProfileService.updateCurrentProfile(this.userDataProfilesService.defaultProfile, false);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export class UserDataProfileService extends Disposable implements IUserDataProfi
}

async updateCurrentProfile(userDataProfile: IUserDataProfile, preserveData: boolean): Promise<void> {
if (this._currentProfile.id === userDataProfile.id) {
return;
}
const previous = this._currentProfile;
this._currentProfile = userDataProfile;
if (this._currentProfile.id === previous.id) {
return;
}
const joiners: Promise<void>[] = [];
this._onDidChangeCurrentProfile.fire({
preserveData,
Expand Down

0 comments on commit 0d3e7e6

Please sign in to comment.