Skip to content

Commit

Permalink
Tree checkboxes don't always get API proposal check (microsoft#174066)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexr00 authored and c-claeys committed Feb 16, 2023
1 parent 5c7e8dd commit 591637e
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2494,10 +2494,23 @@ export class TreeItem {
checkboxState?: vscode.TreeItemCheckboxState;

static isTreeItem(thing: any, extension: IExtensionDescription): thing is TreeItem {
const treeItemThing = thing as vscode.TreeItem2;

if (treeItemThing.checkboxState !== undefined) {
checkProposedApiEnabled(extension, 'treeItemCheckbox');
const checkbox = isNumber(treeItemThing.checkboxState) ? treeItemThing.checkboxState :
isObject(treeItemThing.checkboxState) && isNumber(treeItemThing.checkboxState.state) ? treeItemThing.checkboxState.state : undefined;
const tooltip = !isNumber(treeItemThing.checkboxState) && isObject(treeItemThing.checkboxState) ? treeItemThing.checkboxState.tooltip : undefined;
if (checkbox === undefined || (checkbox !== TreeItemCheckboxState.Checked && checkbox !== TreeItemCheckboxState.Unchecked) || (tooltip !== undefined && !isString(tooltip))) {
console.log('INVALID tree item, invalid checkboxState', treeItemThing.checkboxState);
return false;
}
}

if (thing instanceof TreeItem) {
return true;
}
const treeItemThing = thing as vscode.TreeItem2;

if (treeItemThing.label !== undefined && !isString(treeItemThing.label) && !(treeItemThing.label?.label)) {
console.log('INVALID tree item, invalid label', treeItemThing.label);
return false;
Expand Down Expand Up @@ -2541,16 +2554,6 @@ export class TreeItem {
console.log('INVALID tree item, invalid accessibilityInformation', treeItemThing.accessibilityInformation);
return false;
}
if (treeItemThing.checkboxState !== undefined) {
checkProposedApiEnabled(extension, 'treeItemCheckbox');
const checkbox = isNumber(treeItemThing.checkboxState) ? treeItemThing.checkboxState :
isObject(treeItemThing.checkboxState) && isNumber(treeItemThing.checkboxState.state) ? treeItemThing.checkboxState.state : undefined;
const tooltip = !isNumber(treeItemThing.checkboxState) && isObject(treeItemThing.checkboxState) ? treeItemThing.checkboxState.tooltip : undefined;
if (checkbox === undefined || (checkbox !== TreeItemCheckboxState.Checked && checkbox !== TreeItemCheckboxState.Unchecked) || (tooltip !== undefined && !isString(tooltip))) {
console.log('INVALID tree item, invalid checkboxState', treeItemThing.checkboxState);
return false;
}
}

return true;
}
Expand Down

0 comments on commit 591637e

Please sign in to comment.