Skip to content

Commit e3da634

Browse files
authored
* fix microsoft#153183 * fix compilation
1 parent 8d88866 commit e3da634

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type WillRemoveProfileEvent = {
2828

2929
export const IUserDataProfilesMainService = refineServiceDecorator<IUserDataProfilesService, IUserDataProfilesMainService>(IUserDataProfilesService);
3030
export interface IUserDataProfilesMainService extends IUserDataProfilesService {
31+
unsetWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): Promise<void>;
3132
readonly onWillCreateProfile: Event<WillCreateProfileEvent>;
3233
readonly onWillRemoveProfile: Event<WillRemoveProfileEvent>;
3334
}
@@ -106,6 +107,14 @@ export class UserDataProfilesMainService extends UserDataProfilesService impleme
106107
return this.profilesObject.profiles.find(p => this.uriIdentityService.extUri.isEqual(p.location, profile.location))!;
107108
}
108109

110+
async unsetWorkspace(workspaceIdentifier: ISingleFolderWorkspaceIdentifier | IWorkspaceIdentifier): Promise<void> {
111+
if (!this.enabled) {
112+
throw new Error(`Settings Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);
113+
}
114+
const workspace = this.getWorkspace(workspaceIdentifier);
115+
this.setStoredWorskpaceInfos(this.getStoredWorskpaceInfos().filter(info => !this.uriIdentityService.extUri.isEqual(info.workspace, workspace)));
116+
}
117+
109118
override async removeProfile(profile: IUserDataProfile): Promise<void> {
110119
if (!this.enabled) {
111120
throw new Error(`Settings Profiles are disabled. Enable them via the '${PROFILES_ENABLEMENT_CONFIG}' setting.`);

src/vs/platform/workspaces/electron-main/workspacesManagementMainService.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IEnvironmentMainService } from 'vs/platform/environment/electron-main/e
2323
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
2424
import { ILogService } from 'vs/platform/log/common/log';
2525
import { IProductService } from 'vs/platform/product/common/productService';
26+
import { IUserDataProfilesMainService } from 'vs/platform/userDataProfile/electron-main/userDataProfile';
2627
import { ICodeWindow } from 'vs/platform/window/electron-main/window';
2728
import { findWindowOnWorkspaceOrFolder } from 'vs/platform/windows/electron-main/windowsFinder';
2829
import { isWorkspaceIdentifier, IWorkspaceIdentifier, IResolvedWorkspace, hasWorkspaceFileExtension, UNTITLED_WORKSPACE_NAME, isUntitledWorkspace } from 'vs/platform/workspace/common/workspace';
@@ -75,6 +76,7 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
7576
constructor(
7677
@IEnvironmentMainService private readonly environmentMainService: IEnvironmentMainService,
7778
@ILogService private readonly logService: ILogService,
79+
@IUserDataProfilesMainService private readonly userDataProfilesMainService: IUserDataProfilesMainService,
7880
@IBackupMainService private readonly backupMainService: IBackupMainService,
7981
@IDialogMainService private readonly dialogMainService: IDialogMainService,
8082
@IProductService private readonly productService: IProductService
@@ -203,6 +205,9 @@ export class WorkspacesManagementMainService extends Disposable implements IWork
203205
// Delete from disk
204206
this.doDeleteUntitledWorkspaceSync(workspace);
205207

208+
// unset workspace from profiles
209+
this.userDataProfilesMainService.unsetWorkspace(workspace);
210+
206211
// Event
207212
this._onDidDeleteUntitledWorkspace.fire(workspace);
208213
}

src/vs/platform/workspaces/test/electron-main/workspacesManagementMainService.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ import { INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs';
2020
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogMainService';
2121
import { EnvironmentMainService } from 'vs/platform/environment/electron-main/environmentMainService';
2222
import { OPTIONS, parseArgs } from 'vs/platform/environment/node/argv';
23+
import { FileService } from 'vs/platform/files/common/fileService';
2324
import { NullLogService } from 'vs/platform/log/common/log';
2425
import product from 'vs/platform/product/common/product';
2526
import { IProductService } from 'vs/platform/product/common/productService';
27+
import { StateMainService } from 'vs/platform/state/electron-main/stateMainService';
28+
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
29+
import { UserDataProfilesMainService } from 'vs/platform/userDataProfile/electron-main/userDataProfile';
2630
import { IRawFileWorkspaceFolder, IRawUriWorkspaceFolder, IWorkspaceIdentifier, WORKSPACE_EXTENSION } from 'vs/platform/workspace/common/workspace';
2731
import { IStoredWorkspace, IStoredWorkspaceFolder, IWorkspaceFolderCreationData, rewriteWorkspaceFileForNewLocation } from 'vs/platform/workspaces/common/workspaces';
2832
import { WorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
@@ -109,7 +113,9 @@ flakySuite('WorkspacesManagementMainService', () => {
109113
}
110114
};
111115

112-
service = new WorkspacesManagementMainService(environmentMainService, new NullLogService(), new TestBackupMainService(), new TestDialogMainService(), productService);
116+
const logService = new NullLogService();
117+
const fileService = new FileService(logService);
118+
service = new WorkspacesManagementMainService(environmentMainService, logService, new UserDataProfilesMainService(new StateMainService(environmentMainService, logService, fileService), new UriIdentityService(fileService), environmentMainService, fileService, logService), new TestBackupMainService(), new TestDialogMainService(), productService);
113119

114120
return pfs.Promises.mkdir(untitledWorkspacesHomePath, { recursive: true });
115121
});

src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ export abstract class AbstractWorkspaceEditingService implements IWorkspaceEditi
245245
}
246246
} else {
247247
path = untitledWorkspace.configPath;
248+
if (!this.userDataProfileService.currentProfile.isDefault) {
249+
await this.userDataProfilesService.setProfileForWorkspace(this.userDataProfileService.currentProfile, untitledWorkspace);
250+
}
248251
}
249252

250253
return this.enterWorkspace(path);

0 commit comments

Comments
 (0)