@@ -20,6 +20,7 @@ import * as emmetHelper from 'emmet-helper'
2020import { isValidLocationForEmmetAbbreviation } from '../util/isValidLocationForEmmetAbbreviation'
2121import { getDocumentSettings } from '../util/getDocumentSettings'
2222import { isJsContext } from '../util/js'
23+ import { naturalExpand } from '../util/naturalExpand'
2324
2425function completionsFromClassList (
2526 state : State ,
@@ -65,15 +66,17 @@ function completionsFromClassList(
6566 return {
6667 isIncomplete : false ,
6768 items : Object . keys ( isSubset ? subset : state . classNames . classNames ) . map (
68- ( className ) => {
69+ ( className , index ) => {
6970 let label = className
7071 let kind : CompletionItemKind = CompletionItemKind . Constant
7172 let documentation : string = null
7273 let command : any
74+ let sortText = naturalExpand ( index )
7375 if ( isContextItem ( state , [ ...subsetKey , className ] ) ) {
7476 kind = CompletionItemKind . Module
7577 command = { title : '' , command : 'editor.action.triggerSuggest' }
7678 label += sep
79+ sortText = '-' + sortText // move to top
7780 } else {
7881 const color = getColor ( state , [ className ] )
7982 if ( color ) {
@@ -87,6 +90,7 @@ function completionsFromClassList(
8790 kind,
8891 documentation,
8992 command,
93+ sortText,
9094 data : [ ...subsetKey , className ] ,
9195 textEdit : {
9296 newText : label ,
@@ -261,7 +265,7 @@ function provideCssHelperCompletions(
261265
262266 return {
263267 isIncomplete : false ,
264- items : Object . keys ( obj ) . map ( ( item ) => {
268+ items : Object . keys ( obj ) . map ( ( item , index ) => {
265269 let color = getColorFromString ( obj [ item ] )
266270 const replaceDot : boolean =
267271 item . indexOf ( '.' ) !== - 1 && separator && separator . endsWith ( '.' )
@@ -272,6 +276,7 @@ function provideCssHelperCompletions(
272276 return {
273277 label : item ,
274278 filterText : `${ replaceDot ? '.' : '' } ${ item } ` ,
279+ sortText : naturalExpand ( index ) ,
275280 kind : color
276281 ? CompletionItemKind . Color
277282 : isObject ( obj [ item ] )
@@ -378,10 +383,11 @@ function provideScreenDirectiveCompletions(
378383
379384 return {
380385 isIncomplete : false ,
381- items : Object . keys ( screens ) . map ( ( screen ) => ( {
386+ items : Object . keys ( screens ) . map ( ( screen , index ) => ( {
382387 label : screen ,
383388 kind : CompletionItemKind . Constant ,
384389 data : 'screen' ,
390+ sortText : naturalExpand ( index ) ,
385391 textEdit : {
386392 newText : screen ,
387393 range : {
0 commit comments