Skip to content

Commit 996a47c

Browse files
committed
fix: sort negated directives last
1 parent 2957a9a commit 996a47c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/language-service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,18 @@ const collator = new Intl.Collator(undefined, {
4545
caseFirst: 'false',
4646
})
4747

48-
const baseSort: NonNullable<MatchSorterOptions<CompletionToken>['baseSort']> = (a, b) =>
49-
collator.compare(a.item.label, b.item.label)
48+
const baseSort: NonNullable<MatchSorterOptions<CompletionToken>['baseSort']> = (a, b) => {
49+
// Sort negated labels last
50+
if (a.item.label[0] == '-' && b.item.label[0] != '-') {
51+
return 1
52+
}
53+
54+
if (a.item.label[0] != '-' && b.item.label[0] == '-') {
55+
return -1
56+
}
57+
58+
return collator.compare(a.item.label, b.item.label)
59+
}
5060

5161
// By default, match-sorter assumes spaces to be the word separator.
5262
// Lets split the text into whitespace separated words

0 commit comments

Comments
 (0)