@@ -182,7 +182,7 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
182182 } ;
183183 } ) ( ) ;
184184
185- return this . supportLevels
185+ const supportLevels = this . supportLevels
186186 . filter (
187187 ( supportLevel ) =>
188188 supportLevel . support === scopeSupport &&
@@ -201,26 +201,11 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
201201 isEqual ( supportLevel . scopeType , this . scopeVisualizer . scopeType ) ,
202202 getContainmentIcon ?.( supportLevel . scopeType ) ,
203203 ) ,
204- )
205- . sort ( ( a , b ) => {
206- if (
207- a . scopeTypeInfo . spokenForm . type !== b . scopeTypeInfo . spokenForm . type
208- ) {
209- // Scopes with no spoken form are sorted to the bottom
210- return a . scopeTypeInfo . spokenForm . type === "error" ? 1 : - 1 ;
211- }
204+ ) ;
212205
213- if (
214- a . scopeTypeInfo . isLanguageSpecific !==
215- b . scopeTypeInfo . isLanguageSpecific
216- ) {
217- // Then language-specific scopes are sorted to the top
218- return a . scopeTypeInfo . isLanguageSpecific ? - 1 : 1 ;
219- }
206+ supportLevels . sort ( compareScopeTypes ) ;
220207
221- // Then alphabetical by label
222- return a . label . label . localeCompare ( b . label . label ) ;
223- } ) ;
208+ return supportLevels ;
224209 }
225210
226211 private getContainmentIcon (
@@ -255,6 +240,26 @@ export class ScopeTreeProvider implements TreeDataProvider<MyTreeItem> {
255240 }
256241}
257242
243+ function compareScopeTypes (
244+ a : ScopeSupportTreeItem ,
245+ b : ScopeSupportTreeItem ,
246+ ) : number {
247+ if ( a . scopeTypeInfo . spokenForm . type !== b . scopeTypeInfo . spokenForm . type ) {
248+ // Scopes with no spoken form are sorted to the bottom
249+ return a . scopeTypeInfo . spokenForm . type === "error" ? 1 : - 1 ;
250+ }
251+
252+ if (
253+ a . scopeTypeInfo . isLanguageSpecific !== b . scopeTypeInfo . isLanguageSpecific
254+ ) {
255+ // Then language-specific scopes are sorted to the top
256+ return a . scopeTypeInfo . isLanguageSpecific ? - 1 : 1 ;
257+ }
258+
259+ // Then alphabetical by label
260+ return a . label . label . localeCompare ( b . label . label ) ;
261+ }
262+
258263function getSupportCategories ( ) : SupportCategoryTreeItem [ ] {
259264 return [
260265 new SupportCategoryTreeItem ( ScopeSupport . supportedAndPresentInEditor ) ,
0 commit comments