Skip to content

Commit e7a9f82

Browse files
committed
[html] only enable embedded content support on demand
1 parent 1b2478d commit e7a9f82

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

extensions/html/client/src/htmlMain.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export function activate(context: ExtensionContext) {
5959
// Synchronize the setting section 'html' to the server
6060
configurationSection: ['html'],
6161
},
62+
6263
initializationOptions: {
64+
embeddedLanguages: { 'css': true },
6365
['format.enable']: workspace.getConfiguration('html').get('format.enable')
6466
}
6567
};

extensions/html/server/src/htmlServerMain.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ connection.onShutdown(() => {
7474
});
7575

7676
let workspacePath: string;
77+
let embeddedLanguages: { [languageId: string]: boolean };
7778

7879
// After the server has started the client sends an initilize request. The server receives
7980
// in the passed params the rootPath of the workspace plus the client capabilites
8081
connection.onInitialize((params: InitializeParams): InitializeResult => {
8182
workspacePath = params.rootPath;
83+
embeddedLanguages = params.initializationOptions.embeddedLanguages;
8284
return {
8385
capabilities: {
8486
// Tell the client that the server works in FULL text document sync mode
@@ -118,9 +120,9 @@ connection.onCompletion(textDocumentPosition => {
118120
let htmlDocument = htmlDocuments.get(document);
119121
let options = languageSettings && languageSettings.suggest;
120122
let list = languageService.doComplete(document, textDocumentPosition.position, htmlDocument, options);
121-
if (list.items.length === 0) {
123+
if (list.items.length === 0 && embeddedLanguages) {
122124
let embeddedLanguageId = getEmbeddedLanguageAtPosition(languageService, document, htmlDocument, textDocumentPosition.position);
123-
if (embeddedLanguageId) {
125+
if (embeddedLanguageId && embeddedLanguages[embeddedLanguageId]) {
124126
return connection.sendRequest(EmbeddedCompletionRequest.type, { uri: document.uri, version: document.version, embeddedLanguageId, position: textDocumentPosition.position });
125127
}
126128
}
@@ -131,9 +133,9 @@ connection.onHover(textDocumentPosition => {
131133
let document = documents.get(textDocumentPosition.textDocument.uri);
132134
let htmlDocument = htmlDocuments.get(document);
133135
let hover = languageService.doHover(document, textDocumentPosition.position, htmlDocument);
134-
if (!hover) {
136+
if (!hover && embeddedLanguages) {
135137
let embeddedLanguageId = getEmbeddedLanguageAtPosition(languageService, document, htmlDocument, textDocumentPosition.position);
136-
if (embeddedLanguageId) {
138+
if (embeddedLanguageId && embeddedLanguages[embeddedLanguageId]) {
137139
return connection.sendRequest(EmbeddedHoverRequest.type, { uri: document.uri, version: document.version, embeddedLanguageId, position: textDocumentPosition.position });
138140
}
139141
}

0 commit comments

Comments
 (0)