diff --git a/extensions/json/client/src/jsonMain.ts b/extensions/json/client/src/jsonMain.ts index 7dc61a32e1c..a00cc5ca01f 100644 --- a/extensions/json/client/src/jsonMain.ts +++ b/extensions/json/client/src/jsonMain.ts @@ -68,25 +68,26 @@ export function activate(context: ExtensionContext) { // Create the language client and start the client. let client = new LanguageClient('json', localize('jsonserver.name', 'JSON Language Server'), serverOptions, clientOptions); - client.onTelemetry(e => { - if (telemetryReporter) { - telemetryReporter.sendTelemetryEvent(e.key, e.data); - } - }); - - // handle content request - client.onRequest(VSCodeContentRequest.type, (uriPath: string) => { - let uri = Uri.parse(uriPath); - return workspace.openTextDocument(uri).then(doc => { - return doc.getText(); - }, error => { - return Promise.reject(error); - }); - }); - let disposable = client.start(); + client.onReady().then(() => { + client.onTelemetry(e => { + if (telemetryReporter) { + telemetryReporter.sendTelemetryEvent(e.key, e.data); + } + }); - client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context)); + // handle content request + client.onRequest(VSCodeContentRequest.type, (uriPath: string) => { + let uri = Uri.parse(uriPath); + return workspace.openTextDocument(uri).then(doc => { + return doc.getText(); + }, error => { + return Promise.reject(error); + }); + }); + + client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context)); + }); // Push the disposable to the context's subscriptions so that the // client can be deactivated on extension deactivation