aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/ctx.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r--editors/code/src/ctx.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts
index 13988056a..a2a4e42a9 100644
--- a/editors/code/src/ctx.ts
+++ b/editors/code/src/ctx.ts
@@ -1,7 +1,7 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3import { Config } from './config'; 3import { Config } from './config';
4import { createClient } from './client' 4import { createClient } from './client';
5 5
6export class Ctx { 6export class Ctx {
7 readonly config: Config; 7 readonly config: Config;
@@ -10,28 +10,28 @@ export class Ctx {
10 // deal with it. 10 // deal with it.
11 // 11 //
12 // Ideally, this should be replaced with async getter though. 12 // Ideally, this should be replaced with async getter though.
13 client: lc.LanguageClient | null = null 13 client: lc.LanguageClient | null = null;
14 private extCtx: vscode.ExtensionContext; 14 private extCtx: vscode.ExtensionContext;
15 private onDidRestartHooks: Array<(client: lc.LanguageClient) => void> = []; 15 private onDidRestartHooks: Array<(client: lc.LanguageClient) => void> = [];
16 16
17 constructor(extCtx: vscode.ExtensionContext) { 17 constructor(extCtx: vscode.ExtensionContext) {
18 this.config = new Config(extCtx) 18 this.config = new Config(extCtx);
19 this.extCtx = extCtx; 19 this.extCtx = extCtx;
20 } 20 }
21 21
22 async restartServer() { 22 async restartServer() {
23 let old = this.client; 23 let old = this.client;
24 if (old) { 24 if (old) {
25 await old.stop() 25 await old.stop();
26 } 26 }
27 this.client = null; 27 this.client = null;
28 const client = createClient(this.config); 28 const client = createClient(this.config);
29 this.pushCleanup(client.start()); 29 this.pushCleanup(client.start());
30 await client.onReady(); 30 await client.onReady();
31 31
32 this.client = client 32 this.client = client;
33 for (const hook of this.onDidRestartHooks) { 33 for (const hook of this.onDidRestartHooks) {
34 hook(client) 34 hook(client);
35 } 35 }
36 } 36 }
37 37
@@ -80,7 +80,7 @@ export class Ctx {
80 } 80 }
81 81
82 onDidRestart(hook: (client: lc.LanguageClient) => void) { 82 onDidRestart(hook: (client: lc.LanguageClient) => void) {
83 this.onDidRestartHooks.push(hook) 83 this.onDidRestartHooks.push(hook);
84 } 84 }
85} 85}
86 86