@@ -20,6 +20,7 @@ import * as emmetHelper from 'emmet-helper'
20
20
import { isValidLocationForEmmetAbbreviation } from '../util/isValidLocationForEmmetAbbreviation'
21
21
import { getDocumentSettings } from '../util/getDocumentSettings'
22
22
import { isJsContext } from '../util/js'
23
+ import { naturalExpand } from '../util/naturalExpand'
23
24
24
25
function completionsFromClassList (
25
26
state : State ,
@@ -65,15 +66,17 @@ function completionsFromClassList(
65
66
return {
66
67
isIncomplete : false ,
67
68
items : Object . keys ( isSubset ? subset : state . classNames . classNames ) . map (
68
- ( className ) => {
69
+ ( className , index ) => {
69
70
let label = className
70
71
let kind : CompletionItemKind = CompletionItemKind . Constant
71
72
let documentation : string = null
72
73
let command : any
74
+ let sortText = naturalExpand ( index )
73
75
if ( isContextItem ( state , [ ...subsetKey , className ] ) ) {
74
76
kind = CompletionItemKind . Module
75
77
command = { title : '' , command : 'editor.action.triggerSuggest' }
76
78
label += sep
79
+ sortText = '-' + sortText // move to top
77
80
} else {
78
81
const color = getColor ( state , [ className ] )
79
82
if ( color ) {
@@ -87,6 +90,7 @@ function completionsFromClassList(
87
90
kind,
88
91
documentation,
89
92
command,
93
+ sortText,
90
94
data : [ ...subsetKey , className ] ,
91
95
textEdit : {
92
96
newText : label ,
@@ -261,7 +265,7 @@ function provideCssHelperCompletions(
261
265
262
266
return {
263
267
isIncomplete : false ,
264
- items : Object . keys ( obj ) . map ( ( item ) => {
268
+ items : Object . keys ( obj ) . map ( ( item , index ) => {
265
269
let color = getColorFromString ( obj [ item ] )
266
270
const replaceDot : boolean =
267
271
item . indexOf ( '.' ) !== - 1 && separator && separator . endsWith ( '.' )
@@ -272,6 +276,7 @@ function provideCssHelperCompletions(
272
276
return {
273
277
label : item ,
274
278
filterText : `${ replaceDot ? '.' : '' } ${ item } ` ,
279
+ sortText : naturalExpand ( index ) ,
275
280
kind : color
276
281
? CompletionItemKind . Color
277
282
: isObject ( obj [ item ] )
@@ -378,10 +383,11 @@ function provideScreenDirectiveCompletions(
378
383
379
384
return {
380
385
isIncomplete : false ,
381
- items : Object . keys ( screens ) . map ( ( screen ) => ( {
386
+ items : Object . keys ( screens ) . map ( ( screen , index ) => ( {
382
387
label : screen ,
383
388
kind : CompletionItemKind . Constant ,
384
389
data : 'screen' ,
390
+ sortText : naturalExpand ( index ) ,
385
391
textEdit : {
386
392
newText : screen ,
387
393
range : {
0 commit comments