mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Double color boxes appear inside style blocks in html files in 1.21. Fixes #43628
This commit is contained in:
parent
2a445d90d2
commit
bcda4bd737
|
@ -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*\}/
|
||||
|
|
|
@ -8,14 +8,12 @@ import * as path from 'path';
|
|||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
import { languages, ExtensionContext, IndentAction, Position, TextDocument, Color, ColorInformation, ColorPresentation, Range, CompletionItem, CompletionItemKind, SnippetString } from 'vscode';
|
||||
import { languages, ExtensionContext, IndentAction, Position, TextDocument, Range, CompletionItem, CompletionItemKind, SnippetString } from 'vscode';
|
||||
import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, RequestType, TextDocumentPositionParams } from 'vscode-languageclient';
|
||||
import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared';
|
||||
import { activateTagClosing } from './tagClosing';
|
||||
import TelemetryReporter from 'vscode-extension-telemetry';
|
||||
|
||||
import { DocumentColorRequest, DocumentColorParams, ColorPresentationRequest, ColorPresentationParams } from 'vscode-languageserver-protocol/lib/protocol.colorProvider.proposed';
|
||||
|
||||
namespace TagCloseRequest {
|
||||
export const type: RequestType<TextDocumentPositionParams, string, any, any> = new RequestType('html/tag');
|
||||
}
|
||||
|
@ -67,37 +65,6 @@ export function activate(context: ExtensionContext) {
|
|||
let disposable = client.start();
|
||||
toDispose.push(disposable);
|
||||
client.onReady().then(() => {
|
||||
disposable = 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, context): 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;
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
toDispose.push(disposable);
|
||||
|
||||
let tagRequestor = (document: TextDocument, position: Position) => {
|
||||
let param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position);
|
||||
return client.sendRequest(TagCloseRequest.type, param);
|
||||
|
|
Loading…
Reference in a new issue