diff options
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r-- | editors/code/src/ctx.ts | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index ff6245f78..c06d8ac31 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as vscode from 'vscode'; |
2 | import * as lc from 'vscode-languageclient'; | 2 | import * as lc from 'vscode-languageclient'; |
3 | import { strict as assert } from "assert"; | ||
3 | 4 | ||
4 | import { Config } from './config'; | 5 | import { Config } from './config'; |
5 | import { createClient } from './client'; | 6 | import { createClient } from './client'; |
@@ -16,19 +17,15 @@ export class Ctx { | |||
16 | // on the event loop to get a better picture of what we can do here) | 17 | // on the event loop to get a better picture of what we can do here) |
17 | client: lc.LanguageClient | null = null; | 18 | client: lc.LanguageClient | null = null; |
18 | private extCtx: vscode.ExtensionContext; | 19 | private extCtx: vscode.ExtensionContext; |
19 | private onDidRestartHooks: Array<(client: lc.LanguageClient) => void> = []; | ||
20 | 20 | ||
21 | constructor(extCtx: vscode.ExtensionContext) { | 21 | constructor(extCtx: vscode.ExtensionContext) { |
22 | this.config = new Config(extCtx); | 22 | this.config = new Config(extCtx); |
23 | this.extCtx = extCtx; | 23 | this.extCtx = extCtx; |
24 | } | 24 | } |
25 | 25 | ||
26 | async restartServer() { | 26 | async startServer() { |
27 | const old = this.client; | 27 | assert(this.client == null); |
28 | if (old) { | 28 | |
29 | await old.stop(); | ||
30 | } | ||
31 | this.client = null; | ||
32 | const client = await createClient(this.config); | 29 | const client = await createClient(this.config); |
33 | if (!client) { | 30 | if (!client) { |
34 | throw new Error( | 31 | throw new Error( |
@@ -41,9 +38,6 @@ export class Ctx { | |||
41 | await client.onReady(); | 38 | await client.onReady(); |
42 | 39 | ||
43 | this.client = client; | 40 | this.client = client; |
44 | for (const hook of this.onDidRestartHooks) { | ||
45 | hook(client); | ||
46 | } | ||
47 | } | 41 | } |
48 | 42 | ||
49 | get activeRustEditor(): vscode.TextEditor | undefined { | 43 | get activeRustEditor(): vscode.TextEditor | undefined { |
@@ -71,10 +65,6 @@ export class Ctx { | |||
71 | pushCleanup(d: Disposable) { | 65 | pushCleanup(d: Disposable) { |
72 | this.extCtx.subscriptions.push(d); | 66 | this.extCtx.subscriptions.push(d); |
73 | } | 67 | } |
74 | |||
75 | onDidRestart(hook: (client: lc.LanguageClient) => void) { | ||
76 | this.onDidRestartHooks.push(hook); | ||
77 | } | ||
78 | } | 68 | } |
79 | 69 | ||
80 | export interface Disposable { | 70 | export interface Disposable { |