Skip to content

Commit f84ac32

Browse files
authored
Check QuickPickButton property shapes before throwing an error (#277216)
1 parent 02ee41c commit f84ac32

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,17 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
399399
}
400400

401401
set buttons(buttons: QuickInputButton[]) {
402-
if (buttons.some(button => button.location || button.toggle)) {
402+
if (buttons.some(button =>
403+
typeof button.location === 'number' ||
404+
typeof button.toggle === 'object' && typeof button.toggle.checked === 'boolean')) {
403405
checkProposedApiEnabled(this._extension, 'quickInputButtonLocation');
404406
}
405407

406-
if (buttons.some(button => button.toggle && button.location !== QuickInputButtonLocation.Input)) {
408+
if (buttons.some(button =>
409+
typeof button.location === 'number' &&
410+
button.location !== QuickInputButtonLocation.Input &&
411+
typeof button.toggle === 'object' &&
412+
typeof button.toggle.checked === 'boolean')) {
407413
throw new Error('QuickInputButtons with toggle set are only supported in the Input location.');
408414
}
409415

@@ -419,8 +425,8 @@ export function createExtHostQuickOpen(mainContext: IMainContext, workspace: IEx
419425
iconPathDto: IconPath.from(button.iconPath),
420426
tooltip: button.tooltip,
421427
handle: button === QuickInputButtons.Back ? -1 : i,
422-
location: button.location,
423-
checked: button.toggle?.checked
428+
location: typeof button.location === 'number' ? button.location : undefined,
429+
checked: typeof button.toggle === 'object' && typeof button.toggle.checked === 'boolean' ? button.toggle.checked : undefined
424430
};
425431
})
426432
});

0 commit comments

Comments
 (0)