Finalize quick pick icon API (#188157)

* [FR] Ability to provide custom icons in QuickPickItem
Fixes #176049

* Remove warning
This commit is contained in:
Alex Ross
2023-07-18 16:08:44 +02:00
committed by GitHub
parent 56aee6465b
commit 8cb6def308
4 changed files with 9 additions and 28 deletions
@@ -86,7 +86,6 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
}
const allowedTooltips = isProposedApiEnabled(extension, 'quickPickItemTooltip');
const allowedIcons = isProposedApiEnabled(extension, 'quickPickItemIcon');
return itemsPromise.then(items => {
@@ -101,10 +100,8 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
if (item.tooltip && !allowedTooltips) {
console.warn(`Extension '${extension.identifier.value}' uses a tooltip which is proposed API that is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.identifier.value}`);
}
if (item.iconPath && !allowedIcons) {
console.warn(`Extension '${extension.identifier.value}' uses an icon which is proposed API that is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.identifier.value}`);
}
const icon = (item.iconPath && allowedIcons) ? getIconPathOrClass(item.iconPath) : undefined;
const icon = (item.iconPath) ? getIconPathOrClass(item.iconPath) : undefined;
pickItems.push({
label: item.label,
iconPath: icon?.iconPath,
@@ -573,7 +570,6 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
});
const allowedTooltips = isProposedApiEnabled(this.extension, 'quickPickItemTooltip');
const allowedIcons = isProposedApiEnabled(this.extension, 'quickPickItemIcon');
const pickItems: TransferQuickPickItemOrSeparator[] = [];
for (let handle = 0; handle < items.length; handle++) {
@@ -584,10 +580,8 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
if (item.tooltip && !allowedTooltips) {
console.warn(`Extension '${this.extension.identifier.value}' uses a tooltip which is proposed API that is only available when running out of dev or with the following command line switch: --enable-proposed-api ${this.extension.identifier.value}`);
}
if (item.iconPath && !allowedIcons) {
console.warn(`Extension '${this.extension.identifier.value}' uses an icon which is proposed API that is only available when running out of dev or with the following command line switch: --enable-proposed-api ${this.extension.identifier.value}`);
}
const icon = (item.iconPath && allowedIcons) ? getIconPathOrClass(item.iconPath) : undefined;
const icon = (item.iconPath) ? getIconPathOrClass(item.iconPath) : undefined;
pickItems.push({
handle,
label: item.label,
@@ -67,7 +67,6 @@ export const allApiProposals = Object.freeze({
portsAttributes: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.portsAttributes.d.ts',
profileContentHandlers: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.profileContentHandlers.d.ts',
quickDiffProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.quickDiffProvider.d.ts',
quickPickItemIcon: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.quickPickItemIcon.d.ts',
quickPickItemTooltip: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.quickPickItemTooltip.d.ts',
quickPickSortByLabel: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.quickPickSortByLabel.d.ts',
readonlyMessage: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.readonlyMessage.d.ts',
+5
View File
@@ -1733,6 +1733,11 @@ declare module 'vscode' {
*/
kind?: QuickPickItemKind;
/**
* The icon path or {@link ThemeIcon} for the QuickPickItem.
*/
iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
/**
* A human-readable string which is rendered less prominent in the same line. Supports rendering of
* {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
-17
View File
@@ -1,17 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
declare module 'vscode' {
/**
* Represents an item that can be selected from
* a list of items.
*/
export interface QuickPickItem {
/**
* The icon path or {@link ThemeIcon} for the QuickPickItem.
*/
iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
}
}