Quick input shouldn't completely break if a ThemeIcon is provided

Part of #72489
This commit is contained in:
Alex Ross 2019-04-24 16:24:56 +02:00
parent b748731f4a
commit 00599b2d60
2 changed files with 6 additions and 3 deletions

View file

@ -255,7 +255,7 @@ class QuickInput implements IQuickInput {
this.ui.leftActionBar.clear();
const leftButtons = this.buttons.filter(button => button === backButton);
this.ui.leftActionBar.push(leftButtons.map((button, index) => {
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath!), true, () => {
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath), true, () => {
this.onDidTriggerButtonEmitter.fire(button);
return Promise.resolve(null);
});
@ -265,7 +265,7 @@ class QuickInput implements IQuickInput {
this.ui.rightActionBar.clear();
const rightButtons = this.buttons.filter(button => button !== backButton);
this.ui.rightActionBar.push(rightButtons.map((button, index) => {
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath!), true, () => {
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath), true, () => {
this.onDidTriggerButtonEmitter.fire(button);
return Promise.resolve(null);
});

View file

@ -11,7 +11,10 @@ import { IdGenerator } from 'vs/base/common/idGenerator';
const iconPathToClass = {};
const iconClassGenerator = new IdGenerator('quick-input-button-icon-');
export function getIconClass(iconPath: { dark: URI; light?: URI; }) {
export function getIconClass(iconPath: { dark: URI; light?: URI; } | undefined): string | undefined {
if (!iconPath) {
return undefined;
}
let iconClass: string;
const key = iconPath.dark.toString();