item sorting
parent
f256aa5176
commit
700cd9e5b4
|
@ -181,6 +181,7 @@ function depthOf(obj) {
|
||||||
|
|
||||||
function createItems(classNames, separator, config, parent = '') {
|
function createItems(classNames, separator, config, parent = '') {
|
||||||
let items = {}
|
let items = {}
|
||||||
|
let i = 0
|
||||||
|
|
||||||
Object.keys(classNames).forEach(key => {
|
Object.keys(classNames).forEach(key => {
|
||||||
if (depthOf(classNames[key]) === 0) {
|
if (depthOf(classNames[key]) === 0) {
|
||||||
|
@ -188,6 +189,7 @@ function createItems(classNames, separator, config, parent = '') {
|
||||||
key,
|
key,
|
||||||
vscode.CompletionItemKind.Constant
|
vscode.CompletionItemKind.Constant
|
||||||
)
|
)
|
||||||
|
item.sortText = naturalExpand(i.toString())
|
||||||
if (key !== 'container' && key !== 'group') {
|
if (key !== 'container' && key !== 'group') {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
item.detail = classNames[key].replace(
|
item.detail = classNames[key].replace(
|
||||||
|
@ -207,26 +209,32 @@ function createItems(classNames, separator, config, parent = '') {
|
||||||
items[key] = {
|
items[key] = {
|
||||||
item
|
item
|
||||||
}
|
}
|
||||||
|
i++
|
||||||
} else {
|
} else {
|
||||||
const item = new vscode.CompletionItem(
|
const item = new vscode.CompletionItem(
|
||||||
`${key}${separator}`,
|
`${key}${separator}`,
|
||||||
vscode.CompletionItemKind.Constant
|
vscode.CompletionItemKind.Constant
|
||||||
)
|
)
|
||||||
|
item.sortText = naturalExpand(i.toString())
|
||||||
item.command = { title: '', command: 'editor.action.triggerSuggest' }
|
item.command = { title: '', command: 'editor.action.triggerSuggest' }
|
||||||
if (key === 'hover' || key === 'focus' || key === 'active') {
|
if (key === 'hover' || key === 'focus' || key === 'active') {
|
||||||
item.detail = `:${key}`
|
item.detail = `:${key}`
|
||||||
|
item.sortText = `a${item.sortText}`
|
||||||
} else if (key === 'group-hover') {
|
} else if (key === 'group-hover') {
|
||||||
item.detail = '.group:hover &'
|
item.detail = '.group:hover &'
|
||||||
|
item.sortText = `a${item.sortText}`
|
||||||
} else if (
|
} else if (
|
||||||
config.screens &&
|
config.screens &&
|
||||||
Object.keys(config.screens).indexOf(key) !== -1
|
Object.keys(config.screens).indexOf(key) !== -1
|
||||||
) {
|
) {
|
||||||
item.detail = `@media (min-width: ${config.screens[key]})`
|
item.detail = `@media (min-width: ${config.screens[key]})`
|
||||||
|
item.sortText = `m${item.sortText}`
|
||||||
}
|
}
|
||||||
items[key] = {
|
items[key] = {
|
||||||
item,
|
item,
|
||||||
children: createItems(classNames[key], separator, config, key)
|
children: createItems(classNames[key], separator, config, key)
|
||||||
}
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue