Skip to content

Commit 75a871b

Browse files
committed
Add icons
1 parent 670c9a5 commit 75a871b

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

packages/cursorless-vscode/src/ScopeSupportTreeProvider.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,17 @@ export class ScopeSupportTreeProvider
9696
getScopeTypesWithSupport(scopeSupport: ScopeSupport): ScopeSupportTreeItem[] {
9797
return this.supportLevels
9898
.filter((supportLevel) => supportLevel.support === scopeSupport)
99-
.map((supportLevel) => new ScopeSupportTreeItem(supportLevel));
99+
.map((supportLevel) => new ScopeSupportTreeItem(supportLevel))
100+
.sort((a, b) => {
101+
if (
102+
a.scopeTypeInfo.isLanguageSpecific !==
103+
b.scopeTypeInfo.isLanguageSpecific
104+
) {
105+
return a.scopeTypeInfo.isLanguageSpecific ? -1 : 1;
106+
}
107+
108+
return a.label.localeCompare(b.label);
109+
});
100110
}
101111

102112
dispose() {
@@ -130,7 +140,9 @@ function getSupportCategories(): SupportCategoryTreeItem[] {
130140
}
131141

132142
class ScopeSupportTreeItem extends vscode.TreeItem {
133-
constructor(scopeTypeInfo: ScopeTypeInfo) {
143+
public label: string;
144+
145+
constructor(public scopeTypeInfo: ScopeTypeInfo) {
134146
const label =
135147
scopeTypeInfo.spokenForm.type === "error"
136148
? "-"
@@ -139,6 +151,8 @@ class ScopeSupportTreeItem extends vscode.TreeItem {
139151

140152
super(label, vscode.TreeItemCollapsibleState.None);
141153

154+
this.label = label;
155+
142156
this.description = description;
143157

144158
if (
@@ -158,6 +172,10 @@ class ScopeSupportTreeItem extends vscode.TreeItem {
158172
],
159173
title: `Visualize ${scopeTypeInfo.humanReadableName}`,
160174
};
175+
176+
if (scopeTypeInfo.isLanguageSpecific) {
177+
this.resourceUri = vscode.window.activeTextEditor?.document.uri;
178+
}
161179
}
162180
}
163181

0 commit comments

Comments
 (0)