From f8ed49c5d331378dfed8f31a6360bac76329bed4 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 9 Nov 2021 10:50:49 -0800 Subject: [PATCH] finalize quickpick APIs --- src/vs/vscode.d.ts | 32 +++++++++++++++++++ src/vs/vscode.proposed.d.ts | 26 --------------- .../workbench/api/common/extHostQuickOpen.ts | 21 ++++++------ 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 6dfa46c6a974e..c2ea239f0dfc0 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -1672,6 +1672,12 @@ declare module 'vscode' { * Always show this item. */ alwaysShow?: boolean; + + /** + * Optional buttons that will be rendered on this particular item. These buttons will trigger + * an {@link QuickPickItemButtonEvent} when clicked. + */ + readonly buttons?: QuickInputButton[]; } /** @@ -10199,6 +10205,12 @@ declare module 'vscode' { */ readonly onDidTriggerButton: Event; + /** + * An event signaling when a button in a particular {@link QuickPickItem} was triggered. + * This event does not fire for buttons in the title bar. + */ + readonly onDidTriggerItemButton: Event>; + /** * Items to pick from. This can be read and updated by the extension. */ @@ -10219,6 +10231,11 @@ declare module 'vscode' { */ matchOnDetail: boolean; + /* + * An optional flag to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false. + */ + keepScrollPosition?: boolean; + /** * Active items. This can be read and updated by the extension. */ @@ -10330,6 +10347,21 @@ declare module 'vscode' { private constructor(); } + /** + * An event signaling when a button in a particular {@link QuickPickItem} was triggered. + * This event does not fire for buttons in the title bar. + */ + export interface QuickPickItemButtonEvent { + /** + * The button that was clicked. + */ + readonly button: QuickInputButton; + /** + * The item that the button belongs to. + */ + readonly item: T; + } + /** * An event describing an individual change in the text of a {@link TextDocument document}. */ diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 7c2f1cf9d0ca0..2edc241ced74d 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1120,18 +1120,6 @@ declare module 'vscode' { //#endregion - //#region https://github.com/microsoft/vscode/issues/132068 - - export interface QuickPick extends QuickInput { - - /* - * An optional flag to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false. - */ - keepScrollPosition?: boolean; - } - - //#endregion - //#region https://github.com/microsoft/vscode/issues/124970, Cell Execution State /** @@ -2803,20 +2791,6 @@ declare module 'vscode' { //#endregion - //#region https://github.com/microsoft/vscode/issues/88716 - export interface QuickPickItem { - buttons?: QuickInputButton[]; - } - export interface QuickPick extends QuickInput { - readonly onDidTriggerItemButton: Event>; - } - export interface QuickPickItemButtonEvent { - button: QuickInputButton; - item: T; - } - - //#endregion - //#region @eamodio https://github.com/microsoft/vscode/issues/133935 export interface SourceControl { diff --git a/src/vs/workbench/api/common/extHostQuickOpen.ts b/src/vs/workbench/api/common/extHostQuickOpen.ts index f05cc14db0250..96374d8e4be3f 100644 --- a/src/vs/workbench/api/common/extHostQuickOpen.ts +++ b/src/vs/workbench/api/common/extHostQuickOpen.ts @@ -193,7 +193,7 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx // ---- QuickInput createQuickPick(extensionId: ExtensionIdentifier, enableProposedApi: boolean): QuickPick { - const session: ExtHostQuickPick = new ExtHostQuickPick(extensionId, enableProposedApi, () => this._sessions.delete(session._id)); + const session: ExtHostQuickPick = new ExtHostQuickPick(extensionId, () => this._sessions.delete(session._id)); this._sessions.set(session._id, session); return session; } @@ -531,7 +531,7 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx private readonly _onDidChangeSelectionEmitter = new Emitter(); private readonly _onDidTriggerItemButtonEmitter = new Emitter>(); - constructor(extensionId: ExtensionIdentifier, private readonly enableProposedApi: boolean, onDispose: () => void) { + constructor(extensionId: ExtensionIdentifier, onDispose: () => void) { super(extensionId, onDispose); this._disposables.push( this._onDidChangeActiveEmitter, @@ -561,16 +561,13 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx detail: item.detail, picked: item.picked, alwaysShow: item.alwaysShow, - // Proposed API only at the moment - buttons: item.buttons && this.enableProposedApi - ? item.buttons.map((button, i) => { - return { - ...getIconPathOrClass(button), - tooltip: button.tooltip, - handle: i - }; - }) - : undefined, + buttons: item.buttons?.map((button, i) => { + return { + ...getIconPathOrClass(button), + tooltip: button.tooltip, + handle: i + }; + }), })) }); }