Skip to content

Commit a7d3488

Browse files
Hide legacy category from scope visualizer in fully migrated languages (#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
1 parent 12c3835 commit a7d3488

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

packages/cursorless-vscode/src/ScopeTreeProvider.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
112112
getChildren(element?: MyTreeItem): MyTreeItem[] {
113113
if (element == null) {
114114
void this.possiblyShowUpdateTalonMessage();
115-
return getSupportCategories();
115+
return getSupportCategories(this.hasLegacyScopes());
116116
}
117117

118118
if (element instanceof SupportCategoryTreeItem) {
@@ -156,7 +156,15 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
156156
}
157157
}
158158

159-
getScopeTypesWithSupport(scopeSupport: ScopeSupport): ScopeSupportTreeItem[] {
159+
private hasLegacyScopes(): boolean {
160+
return this.supportLevels.some(
161+
(supportLevel) => supportLevel.support === ScopeSupport.supportedLegacy,
162+
);
163+
}
164+
165+
private getScopeTypesWithSupport(
166+
scopeSupport: ScopeSupport,
167+
): ScopeSupportTreeItem[] {
160168
return this.supportLevels
161169
.filter(
162170
(supportLevel) =>
@@ -202,11 +210,15 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
202210
}
203211
}
204212

205-
function getSupportCategories(): SupportCategoryTreeItem[] {
213+
function getSupportCategories(
214+
includeLegacy: boolean,
215+
): SupportCategoryTreeItem[] {
206216
return [
207217
new SupportCategoryTreeItem(ScopeSupport.supportedAndPresentInEditor),
208218
new SupportCategoryTreeItem(ScopeSupport.supportedButNotPresentInEditor),
209-
new SupportCategoryTreeItem(ScopeSupport.supportedLegacy),
219+
...(includeLegacy
220+
? [new SupportCategoryTreeItem(ScopeSupport.supportedLegacy)]
221+
: []),
210222
new SupportCategoryTreeItem(ScopeSupport.unsupported),
211223
];
212224
}

0 commit comments

Comments
 (0)