Skip to content

Commit eded89b

Browse files
authored
1 parent 01ad4dd commit eded89b

File tree

3 files changed

+47
-38
lines changed

3 files changed

+47
-38
lines changed

src/vs/workbench/services/issue/browser/issueTroubleshoot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class TroubleshootIssueService extends Disposable implements ITroubleshootIssueS
120120
}
121121

122122
const originalProfile = this.userDataProfileService.currentProfile;
123-
await this.userDataProfileImportExportService.createTemporaryProfile(this.userDataProfileService.currentProfile, localize('troubleshoot issue', "Troubleshoot Issue"), true);
123+
await this.userDataProfileImportExportService.createTroubleshootProfile();
124124
this.state = new TroubleShootState(TroubleshootStage.EXTENSIONS, originalProfile.id);
125125
await this.resume();
126126
}

src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.ts

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,16 @@ export class UserDataProfileImportExportService extends Disposable implements IU
256256
}
257257
}
258258

259-
async createTemporaryProfile(profile: IUserDataProfile, name: string, extensionsDisabled: boolean): Promise<void> {
260-
const userDataProfilesExportState = this.instantiationService.createInstance(UserDataProfileExportState, profile, extensionsDisabled);
259+
async createTroubleshootProfile(): Promise<void> {
260+
const userDataProfilesExportState = this.instantiationService.createInstance(UserDataProfileExportState, this.userDataProfileService.currentProfile, true);
261261
try {
262-
const profileTemplate = await userDataProfilesExportState.getProfileTemplate(name, undefined);
263-
await this.importAndSwitch(profileTemplate, true, true, extensionsDisabled, localize('import', "Create Profile"));
262+
const profileTemplate = await userDataProfilesExportState.getProfileTemplate(localize('troubleshoot issue', "Troubleshoot Issue"), undefined);
263+
await this.progressService.withProgress({
264+
location: ProgressLocation.Notification,
265+
delay: 1000,
266+
sticky: true,
267+
}, progress =>
268+
this.importAndSwitchWithProgress(profileTemplate, true, true, true, message => progress.report({ message: localize('troubleshoot profile progress', "Setting up Troubleshoot Profile: {0}", message) })));
264269
} finally {
265270
userDataProfilesExportState.dispose();
266271
}
@@ -464,40 +469,44 @@ export class UserDataProfileImportExportService extends Disposable implements IU
464469
command: showWindowLogActionId,
465470
}, async (progress) => {
466471
progress.report({ message: localize('Importing profile', "{0} ({1})...", title, profileTemplate.name) });
467-
const profile = await this.getProfileToImport(profileTemplate, temporaryProfile);
468-
if (!profile) {
469-
return undefined;
470-
}
472+
return this.importAndSwitchWithProgress(profileTemplate, temporaryProfile, extensions, extensionsDisabled, message => progress.report({ message: `${title} (${profileTemplate.name}): ${message}` }));
473+
});
474+
}
471475

472-
if (profileTemplate.settings) {
473-
progress.report({ message: localize('progress settings', "{0} ({1}): Applying Settings...", title, profileTemplate.name) });
474-
await this.instantiationService.createInstance(SettingsResource).apply(profileTemplate.settings, profile);
475-
}
476-
if (profileTemplate.keybindings) {
477-
progress.report({ message: localize('progress keybindings', "{0} ({1}): Applying Keyboard Shortcuts...", title, profileTemplate.name) });
478-
await this.instantiationService.createInstance(KeybindingsResource).apply(profileTemplate.keybindings, profile);
479-
}
480-
if (profileTemplate.tasks) {
481-
progress.report({ message: localize('progress tasks', "{0} ({1}): Applying Tasks...", title, profileTemplate.name) });
482-
await this.instantiationService.createInstance(TasksResource).apply(profileTemplate.tasks, profile);
483-
}
484-
if (profileTemplate.snippets) {
485-
progress.report({ message: localize('progress snippets', "{0} ({1}): Applying Snippets...", title, profileTemplate.name) });
486-
await this.instantiationService.createInstance(SnippetsResource).apply(profileTemplate.snippets, profile);
487-
}
488-
if (profileTemplate.globalState) {
489-
progress.report({ message: localize('progress global state', "{0} ({1}): Applying State...", title, profileTemplate.name) });
490-
await this.instantiationService.createInstance(GlobalStateResource).apply(profileTemplate.globalState, profile);
491-
}
492-
if (profileTemplate.extensions && extensions) {
493-
progress.report({ message: localize('progress extensions', "{0} ({1}): Applying Extensions...", title, profileTemplate.name) });
494-
await this.instantiationService.createInstance(ExtensionsResource, extensionsDisabled).apply(profileTemplate.extensions, profile);
495-
}
476+
private async importAndSwitchWithProgress(profileTemplate: IUserDataProfileTemplate, temporaryProfile: boolean, extensions: boolean, extensionsDisabled: boolean, progress: (message: string) => void): Promise<IUserDataProfile | undefined> {
477+
const profile = await this.getProfileToImport(profileTemplate, temporaryProfile);
478+
if (!profile) {
479+
return undefined;
480+
}
496481

497-
progress.report({ message: localize('switching profile', "{0} ({1}): Applying...", title, profileTemplate.name) });
498-
await this.userDataProfileManagementService.switchProfile(profile);
499-
return profile;
500-
});
482+
if (profileTemplate.settings) {
483+
progress(localize('progress settings', "Applying Settings..."));
484+
await this.instantiationService.createInstance(SettingsResource).apply(profileTemplate.settings, profile);
485+
}
486+
if (profileTemplate.keybindings) {
487+
progress(localize('progress keybindings', "{0}ying Keyboard Shortcuts..."));
488+
await this.instantiationService.createInstance(KeybindingsResource).apply(profileTemplate.keybindings, profile);
489+
}
490+
if (profileTemplate.tasks) {
491+
progress(localize('progress tasks', "Applying Tasks..."));
492+
await this.instantiationService.createInstance(TasksResource).apply(profileTemplate.tasks, profile);
493+
}
494+
if (profileTemplate.snippets) {
495+
progress(localize('progress snippets', "Applying Snippets..."));
496+
await this.instantiationService.createInstance(SnippetsResource).apply(profileTemplate.snippets, profile);
497+
}
498+
if (profileTemplate.globalState) {
499+
progress(localize('progress global state', "Applying State..."));
500+
await this.instantiationService.createInstance(GlobalStateResource).apply(profileTemplate.globalState, profile);
501+
}
502+
if (profileTemplate.extensions && extensions) {
503+
progress(localize('progress extensions', "Applying Extensions..."));
504+
await this.instantiationService.createInstance(ExtensionsResource, extensionsDisabled).apply(profileTemplate.extensions, profile);
505+
}
506+
507+
progress(localize('switching profile', " Applying..."));
508+
await this.userDataProfileManagementService.switchProfile(profile);
509+
return profile;
501510
}
502511

503512
private async resolveProfileContent(resource: URI): Promise<string | null> {

src/vs/workbench/services/userDataProfile/common/userDataProfile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export interface IUserDataProfileImportExportService {
8888
importProfile(uri: URI, options?: IProfileImportOptions): Promise<void>;
8989
showProfileContents(): Promise<void>;
9090
createFromCurrentProfile(name: string): Promise<void>;
91-
createTemporaryProfile(from: IUserDataProfile, name: string, extensionsDisabled: boolean): Promise<void>;
91+
createTroubleshootProfile(): Promise<void>;
9292
setProfile(profile: IUserDataProfileTemplate): Promise<void>;
9393
}
9494

0 commit comments

Comments
 (0)