From 2e74e3c95186f9b5c4a9a9518edc33767b13775f Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Tue, 27 Dec 2022 15:28:31 +0100 Subject: [PATCH] fix #167628 (#170110) --- extensions/github/src/importExportProfiles.ts | 1 + .../mainThreadProfilContentHandlers.ts | 3 ++- .../workbench/api/common/extHost.protocol.ts | 2 +- .../common/extHostProfileContentHandler.ts | 2 +- .../userDataProfileImportExportService.ts | 21 ++++--------------- .../userDataProfile/common/userDataProfile.ts | 1 + ...scode.proposed.profileContentHandlers.d.ts | 1 + 7 files changed, 11 insertions(+), 20 deletions(-) diff --git a/extensions/github/src/importExportProfiles.ts b/extensions/github/src/importExportProfiles.ts index a406f12423d..1539e218f94 100644 --- a/extensions/github/src/importExportProfiles.ts +++ b/extensions/github/src/importExportProfiles.ts @@ -13,6 +13,7 @@ import { URL } from 'url'; class GitHubGistProfileContentHandler implements vscode.ProfileContentHandler { readonly name = vscode.l10n.t('GitHub'); + readonly description = vscode.l10n.t('gist'); private _octokit: Promise | undefined; private getOctokit(): Promise { diff --git a/src/vs/workbench/api/browser/mainThreadProfilContentHandlers.ts b/src/vs/workbench/api/browser/mainThreadProfilContentHandlers.ts index 55cb66b3d1d..357f1a2c315 100644 --- a/src/vs/workbench/api/browser/mainThreadProfilContentHandlers.ts +++ b/src/vs/workbench/api/browser/mainThreadProfilContentHandlers.ts @@ -26,9 +26,10 @@ export class MainThreadProfileContentHandlers extends Disposable implements Main this.proxy = context.getProxy(ExtHostContext.ExtHostProfileContentHandlers); } - async $registerProfileContentHandler(id: string, name: string, extensionId: string): Promise { + async $registerProfileContentHandler(id: string, name: string, description: string | undefined, extensionId: string): Promise { this.registeredHandlers.set(id, this.userDataProfileImportExportService.registerProfileContentHandler(id, { name, + description, extensionId, saveProfile: async (name: string, content: string, token: CancellationToken) => { const result = await this.proxy.$saveProfile(id, name, content, token); diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 6f0caacc47b..5433e2149a6 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1087,7 +1087,7 @@ export interface ExtHostUriOpenersShape { } export interface MainThreadProfileContentHandlersShape { - $registerProfileContentHandler(id: string, name: string, extensionId: string): Promise; + $registerProfileContentHandler(id: string, name: string, description: string | undefined, extensionId: string): Promise; $unregisterProfileContentHandler(id: string): Promise; } diff --git a/src/vs/workbench/api/common/extHostProfileContentHandler.ts b/src/vs/workbench/api/common/extHostProfileContentHandler.ts index e12f12c6cd8..4ebc0833f2d 100644 --- a/src/vs/workbench/api/common/extHostProfileContentHandler.ts +++ b/src/vs/workbench/api/common/extHostProfileContentHandler.ts @@ -37,7 +37,7 @@ export class ExtHostProfileContentHandlers implements ExtHostProfileContentHandl } this.handlers.set(id, handler); - this.proxy.$registerProfileContentHandler(id, handler.name, extension.identifier.value); + this.proxy.$registerProfileContentHandler(id, handler.name, handler.description, extension.identifier.value); return toDisposable(() => { this.handlers.delete(id); diff --git a/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.ts b/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.ts index 30a3e1d1e28..94a170888de 100644 --- a/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.ts +++ b/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.ts @@ -410,25 +410,11 @@ export class UserDataProfileImportExportService extends Disposable implements IU if (this.profileContentHandlers.size === 1) { return this.profileContentHandlers.values().next().value; } - const linkHandlers: { id: string; label: string }[] = []; - const fileHandlers: { id: string; label: string }[] = []; - for (const [id, profileContentHandler] of this.profileContentHandlers) { - if (profileContentHandler.extensionId) { - linkHandlers.push({ id, label: profileContentHandler.name }); - } else { - fileHandlers.push({ id, label: profileContentHandler.name }); - } - } const options: QuickPickItem[] = []; - if (linkHandlers.length) { - options.push({ label: localize('link', "link"), type: 'separator' }); - options.push(...linkHandlers); + for (const [id, profileContentHandler] of this.profileContentHandlers) { + options.push({ id, label: profileContentHandler.name, description: profileContentHandler.description }); } - if (fileHandlers.length) { - options.push({ label: localize('file', "file"), type: 'separator' }); - options.push(...fileHandlers); - } - const result = await this.quickInputService.pick(options, + const result = await this.quickInputService.pick(options.reverse(), { title: localize('select profile content handler', "Export '{0}' profile as...", name), hideInput: true @@ -599,6 +585,7 @@ export class UserDataProfileImportExportService extends Disposable implements IU class FileUserDataProfileContentHandler implements IUserDataProfileContentHandler { readonly name = localize('local', "Local"); + readonly description = localize('file', "file"); constructor( @IFileDialogService private readonly fileDialogService: IFileDialogService, diff --git a/src/vs/workbench/services/userDataProfile/common/userDataProfile.ts b/src/vs/workbench/services/userDataProfile/common/userDataProfile.ts index e9b4381ae7f..cd403d0c719 100644 --- a/src/vs/workbench/services/userDataProfile/common/userDataProfile.ts +++ b/src/vs/workbench/services/userDataProfile/common/userDataProfile.ts @@ -112,6 +112,7 @@ export interface ISaveProfileResult { export interface IUserDataProfileContentHandler { readonly name: string; + readonly description?: string; readonly extensionId?: string; saveProfile(name: string, content: string, token: CancellationToken): Promise; readProfile(idOrUri: string | URI, token: CancellationToken): Promise; diff --git a/src/vscode-dts/vscode.proposed.profileContentHandlers.d.ts b/src/vscode-dts/vscode.proposed.profileContentHandlers.d.ts index e66bcc0f439..d1c3d011640 100644 --- a/src/vscode-dts/vscode.proposed.profileContentHandlers.d.ts +++ b/src/vscode-dts/vscode.proposed.profileContentHandlers.d.ts @@ -7,6 +7,7 @@ declare module 'vscode' { export interface ProfileContentHandler { readonly name: string; + readonly description?: string; saveProfile(name: string, content: string, token: CancellationToken): Thenable<{ readonly id: string; readonly link: Uri } | null>; readProfile(idOrUri: string | Uri, token: CancellationToken): Thenable; }