From a603e8a765ea1cce688af291db60e7fe7e02c07c Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Mon, 28 Nov 2016 10:56:59 +0100 Subject: [PATCH] [html] wait for onReady before using client --- extensions/html/client/src/htmlMain.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/extensions/html/client/src/htmlMain.ts b/extensions/html/client/src/htmlMain.ts index 79de03d9f87..85fefd16523 100644 --- a/extensions/html/client/src/htmlMain.ts +++ b/extensions/html/client/src/htmlMain.ts @@ -50,17 +50,14 @@ export function activate(context: ExtensionContext) { // Create the language client and start the client. let client = new LanguageClient('html', localize('htmlserver.name', 'HTML Language Server'), serverOptions, clientOptions, true); 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); - - let colorRequestor = (uri: string) => { - return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange)); - }; - disposable = activateColorDecorations(colorRequestor, { html: true, handlebars: true, razor: true }); - context.subscriptions.push(disposable); - + client.onReady().then(() => { + let colorRequestor = (uri: string) => { + return client.sendRequest(ColorSymbolRequest.type, uri).then(ranges => ranges.map(client.protocol2CodeConverter.asRange)); + }; + let disposable = activateColorDecorations(colorRequestor, { html: true, handlebars: true, razor: true }); + context.subscriptions.push(disposable); + }); languages.setLanguageConfiguration('html', { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\$\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\s]+)/g,