Skip to content

Commit 4d96f64

Browse files
Hide legacy scope from scope visualizer in fully migrated languages
1 parent 301b2d8 commit 4d96f64

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

packages/cursorless-vscode/src/ScopeTreeProvider.ts

Lines changed: 29 additions & 9 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,13 +210,25 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
202210
}
203211
}
204212

205-
function getSupportCategories(): SupportCategoryTreeItem[] {
206-
return [
207-
new SupportCategoryTreeItem(ScopeSupport.supportedAndPresentInEditor),
208-
new SupportCategoryTreeItem(ScopeSupport.supportedButNotPresentInEditor),
209-
new SupportCategoryTreeItem(ScopeSupport.supportedLegacy),
210-
new SupportCategoryTreeItem(ScopeSupport.unsupported),
211-
];
213+
function getSupportCategories(
214+
includeLegacy: boolean,
215+
): SupportCategoryTreeItem[] {
216+
return includeLegacy
217+
? [
218+
new SupportCategoryTreeItem(ScopeSupport.supportedAndPresentInEditor),
219+
new SupportCategoryTreeItem(
220+
ScopeSupport.supportedButNotPresentInEditor,
221+
),
222+
new SupportCategoryTreeItem(ScopeSupport.supportedLegacy),
223+
new SupportCategoryTreeItem(ScopeSupport.unsupported),
224+
]
225+
: [
226+
new SupportCategoryTreeItem(ScopeSupport.supportedAndPresentInEditor),
227+
new SupportCategoryTreeItem(
228+
ScopeSupport.supportedButNotPresentInEditor,
229+
),
230+
new SupportCategoryTreeItem(ScopeSupport.unsupported),
231+
];
212232
}
213233

214234
class ScopeSupportTreeItem extends TreeItem {

0 commit comments

Comments
 (0)