aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-16 18:23:38 +0000
committerAleksey Kladov <[email protected]>2020-03-16 21:02:11 +0000
commitae662617a2bc49d025adaf9c4a8ff2dfa557d36c (patch)
treef321ad0a529283bbb276095da7644d8f1ba663d2 /editors/code/src/main.ts
parent2e9b6320e66cb764b9683a38c284a06b7c35aab6 (diff)
Separate persistent mutable state from config
That way, we clearly see which things are not change, and we also clearly see which things are persistent.
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index bd4661a36..94ecd4dab 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -9,6 +9,7 @@ import { ensureServerBinary } from './installation/server';
9import { Config } from './config'; 9import { Config } from './config';
10import { log } from './util'; 10import { log } from './util';
11import { ensureProperExtensionVersion } from './installation/extension'; 11import { ensureProperExtensionVersion } from './installation/extension';
12import { PersistentState } from './persistent_state';
12 13
13let ctx: Ctx | undefined; 14let ctx: Ctx | undefined;
14 15
@@ -34,13 +35,14 @@ export async function activate(context: vscode.ExtensionContext) {
34 context.subscriptions.push(defaultOnEnter); 35 context.subscriptions.push(defaultOnEnter);
35 36
36 const config = new Config(context); 37 const config = new Config(context);
38 const state = new PersistentState(context);
37 39
38 vscode.workspace.onDidChangeConfiguration(() => ensureProperExtensionVersion(config).catch(log.error)); 40 vscode.workspace.onDidChangeConfiguration(() => ensureProperExtensionVersion(config, state).catch(log.error));
39 41
40 // Don't await the user response here, otherwise we will block the lsp server bootstrap 42 // Don't await the user response here, otherwise we will block the lsp server bootstrap
41 void ensureProperExtensionVersion(config).catch(log.error); 43 void ensureProperExtensionVersion(config, state).catch(log.error);
42 44
43 const serverPath = await ensureServerBinary(config); 45 const serverPath = await ensureServerBinary(config, state);
44 46
45 if (serverPath == null) { 47 if (serverPath == null) {
46 throw new Error( 48 throw new Error(
@@ -53,7 +55,7 @@ export async function activate(context: vscode.ExtensionContext) {
53 // registers its `onDidChangeDocument` handler before us. 55 // registers its `onDidChangeDocument` handler before us.
54 // 56 //
55 // This a horribly, horribly wrong way to deal with this problem. 57 // This a horribly, horribly wrong way to deal with this problem.
56 ctx = await Ctx.create(config, context, serverPath); 58 ctx = await Ctx.create(config, state, context, serverPath);
57 59
58 // Commands which invokes manually via command palette, shortcut, etc. 60 // Commands which invokes manually via command palette, shortcut, etc.
59 ctx.registerCommand('reload', (ctx) => { 61 ctx.registerCommand('reload', (ctx) => {