Adopt CSS for #39441

This commit is contained in:
Pine Wu 2020-01-21 10:41:37 +01:00
parent 1018bfac9c
commit 698d439b7a

View file

@ -45,8 +45,8 @@ export function activate(context: ExtensionContext) {
dataPaths
},
middleware: {
// testing the replace / insert mode
provideCompletionItem(document: TextDocument, position: Position, context: CompletionContext, token: CancellationToken, next: ProvideCompletionItemsSignature): ProviderResult<CompletionItem[] | CompletionList> {
// testing the replace / insert mode
function updateRanges(item: CompletionItem) {
const range = item.range;
if (range instanceof Range && range.end.isAfter(position) && range.start.isBeforeOrEqual(position)) {
@ -54,9 +54,23 @@ export function activate(context: ExtensionContext) {
}
}
function updateLabel(item: CompletionItem) {
if (item.kind === CompletionItemKind.Color) {
item.label2 = {
name: item.label,
type: (item.documentation as string)
};
}
const range = item.range;
if (range instanceof Range && range.end.isAfter(position) && range.start.isBeforeOrEqual(position)) {
item.range = { inserting: new Range(range.start, position), replacing: range };
}
}
// testing the new completion
function updateProposals(r: CompletionItem[] | CompletionList | null | undefined): CompletionItem[] | CompletionList | null | undefined {
if (r) {
(Array.isArray(r) ? r : r.items).forEach(updateRanges);
(Array.isArray(r) ? r : r.items).forEach(updateLabel);
}
return r;
}