Skip to content

Commit 698d439

Browse files
committed
Adopt CSS for microsoft#39441
1 parent 1018bfa commit 698d439

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

  • extensions/css-language-features/client/src

extensions/css-language-features/client/src/cssMain.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,32 @@ export function activate(context: ExtensionContext) {
4545
dataPaths
4646
},
4747
middleware: {
48-
// testing the replace / insert mode
4948
provideCompletionItem(document: TextDocument, position: Position, context: CompletionContext, token: CancellationToken, next: ProvideCompletionItemsSignature): ProviderResult<CompletionItem[] | CompletionList> {
49+
// testing the replace / insert mode
5050
function updateRanges(item: CompletionItem) {
5151
const range = item.range;
5252
if (range instanceof Range && range.end.isAfter(position) && range.start.isBeforeOrEqual(position)) {
5353
item.range = { inserting: new Range(range.start, position), replacing: range };
5454

5555
}
5656
}
57+
function updateLabel(item: CompletionItem) {
58+
if (item.kind === CompletionItemKind.Color) {
59+
item.label2 = {
60+
name: item.label,
61+
type: (item.documentation as string)
62+
};
63+
}
64+
const range = item.range;
65+
if (range instanceof Range && range.end.isAfter(position) && range.start.isBeforeOrEqual(position)) {
66+
item.range = { inserting: new Range(range.start, position), replacing: range };
67+
}
68+
}
69+
// testing the new completion
5770
function updateProposals(r: CompletionItem[] | CompletionList | null | undefined): CompletionItem[] | CompletionList | null | undefined {
5871
if (r) {
5972
(Array.isArray(r) ? r : r.items).forEach(updateRanges);
73+
(Array.isArray(r) ? r : r.items).forEach(updateLabel);
6074
}
6175
return r;
6276
}

0 commit comments

Comments
 (0)