Skip to content

Commit

Permalink
Hide legacy category from scope visualizer in fully migrated languages (
Browse files Browse the repository at this point in the history
#2727)

When using the scope visualizer for a language that is fully migrated to
our scope handlers I thought it was unnecessary that we showed an empty
legacy category in the scope visualizer.

## Checklist

- [/] I have added
[tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
- [/] I have updated the
[docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and
[cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet)
- [/] I have not broken the cheatsheet
  • Loading branch information
AndreasArvidsson authored Jan 14, 2025
1 parent 12c3835 commit a7d3488
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/cursorless-vscode/src/ScopeTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
getChildren(element?: MyTreeItem): MyTreeItem[] {
if (element == null) {
void this.possiblyShowUpdateTalonMessage();
return getSupportCategories();
return getSupportCategories(this.hasLegacyScopes());
}

if (element instanceof SupportCategoryTreeItem) {
Expand Down Expand Up @@ -156,7 +156,15 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
}
}

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) =>
Expand Down Expand Up @@ -202,11 +210,15 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
}
}

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),
];
}
Expand Down

0 comments on commit a7d3488

Please sign in to comment.