mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Double color boxes appear inside style blocks in html files in 1.21. Fixes #43628
This commit is contained in:
@@ -8,12 +8,9 @@ import * as path from 'path';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { languages, window, commands, ExtensionContext, TextDocument, ColorInformation, ColorPresentation, Color, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString } from 'vscode';
|
||||
import { languages, window, commands, ExtensionContext, Range, Position, CompletionItem, CompletionItemKind, TextEdit, SnippetString } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient';
|
||||
|
||||
import { ConfigurationFeature } from 'vscode-languageclient/lib/configuration.proposed';
|
||||
import { DocumentColorRequest, DocumentColorParams, ColorPresentationRequest, ColorPresentationParams } from 'vscode-languageserver-protocol/lib/protocol.colorProvider.proposed';
|
||||
|
||||
// this method is called when vs code is activated
|
||||
export function activate(context: ExtensionContext) {
|
||||
|
||||
@@ -43,46 +40,13 @@ export function activate(context: ExtensionContext) {
|
||||
|
||||
// Create the language client and start the client.
|
||||
let client = new LanguageClient('css', localize('cssserver.name', 'CSS Language Server'), serverOptions, clientOptions);
|
||||
client.registerFeature(new ConfigurationFeature(client));
|
||||
client.registerProposedFeatures();
|
||||
|
||||
let disposable = client.start();
|
||||
// Push the disposable to the context's subscriptions so that the
|
||||
// client can be deactivated on extension deactivation
|
||||
context.subscriptions.push(disposable);
|
||||
|
||||
client.onReady().then(_ => {
|
||||
// register color provider
|
||||
context.subscriptions.push(languages.registerColorProvider(documentSelector, {
|
||||
provideDocumentColors(document: TextDocument): Thenable<ColorInformation[]> {
|
||||
let params: DocumentColorParams = {
|
||||
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document)
|
||||
};
|
||||
return client.sendRequest(DocumentColorRequest.type, params).then(symbols => {
|
||||
return symbols.map(symbol => {
|
||||
let range = client.protocol2CodeConverter.asRange(symbol.range);
|
||||
let color = new Color(symbol.color.red, symbol.color.green, symbol.color.blue, symbol.color.alpha);
|
||||
return new ColorInformation(range, color);
|
||||
});
|
||||
});
|
||||
},
|
||||
provideColorPresentations(color: Color, context): ColorPresentation[] | Thenable<ColorPresentation[]> {
|
||||
let params: ColorPresentationParams = {
|
||||
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(context.document),
|
||||
color,
|
||||
range: client.code2ProtocolConverter.asRange(context.range)
|
||||
};
|
||||
return client.sendRequest(ColorPresentationRequest.type, params).then(presentations => {
|
||||
return presentations.map(p => {
|
||||
let presentation = new ColorPresentation(p.label);
|
||||
presentation.textEdit = p.textEdit && client.protocol2CodeConverter.asTextEdit(p.textEdit);
|
||||
presentation.additionalTextEdits = p.additionalTextEdits && client.protocol2CodeConverter.asTextEdits(p.additionalTextEdits);
|
||||
return presentation;
|
||||
});
|
||||
});
|
||||
}
|
||||
}));
|
||||
});
|
||||
|
||||
let indentationRules = {
|
||||
increaseIndentPattern: /(^.*\{[^}]*$)/,
|
||||
decreaseIndentPattern: /^\s*\}/
|
||||
|
||||
Reference in New Issue
Block a user