Skip to content

Commit ad063b9

Browse files
committed
ThemeIcon support (fixes microsoft#72489)
1 parent 8c2a259 commit ad063b9

3 files changed

Lines changed: 30 additions & 29 deletions

File tree

src/vs/workbench/api/browser/mainThreadQuickOpen.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ExtHostContext, MainThreadQuickOpenShape, ExtHostQuickOpenShape, Transf
88
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
99
import { URI } from 'vs/base/common/uri';
1010
import { CancellationToken } from 'vs/base/common/cancellation';
11+
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
1112

1213
interface QuickInputSession {
1314
input: IQuickInput;
@@ -185,14 +186,22 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
185186
return this._quickInputService.backButton;
186187
}
187188
const { iconPath, tooltip, handle } = button;
188-
return {
189-
iconPath: iconPath && {
190-
dark: URI.revive(iconPath.dark),
191-
light: iconPath.light && URI.revive(iconPath.light)
192-
},
193-
tooltip,
194-
handle
195-
};
189+
if ('id' in iconPath) {
190+
return {
191+
iconClass: ThemeIcon.asClassName(iconPath),
192+
tooltip,
193+
handle
194+
};
195+
} else {
196+
return {
197+
iconPath: {
198+
dark: URI.revive(iconPath.dark),
199+
light: iconPath.light && URI.revive(iconPath.light)
200+
},
201+
tooltip,
202+
handle
203+
};
204+
}
196205
});
197206
} else {
198207
(input as any)[param] = params[param];

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,10 @@ export interface TransferQuickPickItems extends quickInput.IQuickPickItem {
439439
handle: number;
440440
}
441441

442-
export interface TransferQuickInputButton extends quickInput.IQuickInputButton {
442+
export interface TransferQuickInputButton {
443443
handle: number;
444+
iconPath: { dark: URI; light?: URI; } | { id: string; };
445+
tooltip?: string;
444446
}
445447

446448
export type TransferQuickInput = TransferQuickPick | TransferInputBox;

src/vs/workbench/api/common/extHostQuickOpen.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -443,31 +443,21 @@ class ExtHostQuickInput implements QuickInput {
443443
}
444444
}
445445

446-
function getIconUris(iconPath: QuickInputButton['iconPath']): { dark: URI, light?: URI } | undefined {
447-
const dark = getDarkIconUri(iconPath);
448-
const light = getLightIconUri(iconPath);
449-
if (!light && !dark) {
450-
return undefined;
446+
function getIconUris(iconPath: QuickInputButton['iconPath']): { dark: URI, light?: URI } | { id: string } {
447+
if (iconPath instanceof ThemeIcon) {
448+
return { id: iconPath.id };
451449
}
452-
return { dark: (dark || light)!, light };
450+
const dark = getDarkIconUri(iconPath as any);
451+
const light = getLightIconUri(iconPath as any);
452+
return { dark, light };
453453
}
454454

455-
function getLightIconUri(iconPath: QuickInputButton['iconPath']) {
456-
if (iconPath && !(iconPath instanceof ThemeIcon)) {
457-
if (typeof iconPath === 'string'
458-
|| URI.isUri(iconPath)) {
459-
return getIconUri(iconPath);
460-
}
461-
return getIconUri((iconPath as any).light);
462-
}
463-
return undefined;
455+
function getLightIconUri(iconPath: string | URI | { light: URI; dark: URI; }) {
456+
return getIconUri(typeof iconPath === 'object' && 'light' in iconPath ? iconPath.light : iconPath);
464457
}
465458

466-
function getDarkIconUri(iconPath: QuickInputButton['iconPath']) {
467-
if (iconPath && !(iconPath instanceof ThemeIcon) && (iconPath as any).dark) {
468-
return getIconUri((iconPath as any).dark);
469-
}
470-
return undefined;
459+
function getDarkIconUri(iconPath: string | URI | { light: URI; dark: URI; }) {
460+
return getIconUri(typeof iconPath === 'object' && 'dark' in iconPath ? iconPath.dark : iconPath);
471461
}
472462

473463
function getIconUri(iconPath: string | URI) {

0 commit comments

Comments
 (0)