Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree checkboxes don't always get API proposal check #174066

Merged
merged 1 commit into from Feb 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/vs/workbench/api/common/extHostTypes.ts
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