diff --git a/packages/cursorless-vscode/src/ScopeTreeProvider.ts b/packages/cursorless-vscode/src/ScopeTreeProvider.ts index b9d1aa3d8b..75f3e20c8a 100644 --- a/packages/cursorless-vscode/src/ScopeTreeProvider.ts +++ b/packages/cursorless-vscode/src/ScopeTreeProvider.ts @@ -112,7 +112,7 @@ export class ScopeTreeProvider implements TreeDataProvider { getChildren(element?: MyTreeItem): MyTreeItem[] { if (element == null) { void this.possiblyShowUpdateTalonMessage(); - return getSupportCategories(); + return getSupportCategories(this.hasLegacyScopes()); } if (element instanceof SupportCategoryTreeItem) { @@ -156,7 +156,15 @@ export class ScopeTreeProvider implements TreeDataProvider { } } - getScopeTypesWithSupport(scopeSupport: ScopeSupport): ScopeSupportTreeItem[] { + private hasLegacyScopes(): boolean { + return this.supportLevels.some( + (supportLevel) => supportLevel.support === ScopeSupport.supportedLegacy, + ); + } + + private getScopeTypesWithSupport( + scopeSupport: ScopeSupport, + ): ScopeSupportTreeItem[] { return this.supportLevels .filter( (supportLevel) => @@ -202,11 +210,15 @@ export class ScopeTreeProvider implements TreeDataProvider { } } -function getSupportCategories(): SupportCategoryTreeItem[] { +function getSupportCategories( + includeLegacy: boolean, +): SupportCategoryTreeItem[] { return [ new SupportCategoryTreeItem(ScopeSupport.supportedAndPresentInEditor), new SupportCategoryTreeItem(ScopeSupport.supportedButNotPresentInEditor), - new SupportCategoryTreeItem(ScopeSupport.supportedLegacy), + ...(includeLegacy + ? [new SupportCategoryTreeItem(ScopeSupport.supportedLegacy)] + : []), new SupportCategoryTreeItem(ScopeSupport.unsupported), ]; }