From 0849f7001cac6af93ce9e9356f8c21881bbe34c5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Dec 2019 17:34:52 +0100 Subject: Refactor config --- editors/code/src/config.ts | 10 ++++------ editors/code/src/ctx.ts | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'editors') diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 9800b461f..ec2790b63 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -43,14 +43,12 @@ export class Config { private prevEnhancedTyping: null | boolean = null; private prevCargoFeatures: null | CargoFeatures = null; - constructor() { - vscode.workspace.onDidChangeConfiguration(_ => - this.userConfigChanged(), - ); - this.userConfigChanged(); + constructor(ctx: vscode.ExtensionContext) { + vscode.workspace.onDidChangeConfiguration(_ => this.refresh(), ctx.subscriptions); + this.refresh(); } - userConfigChanged() { + private refresh() { const config = vscode.workspace.getConfiguration('rust-analyzer'); let requireReloadMessage = null; diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index d86fe5a87..393d6a602 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts @@ -4,10 +4,11 @@ import { Server } from './server'; import { Config } from './config'; export class Ctx { - readonly config = new Config(); + readonly config: Config; private extCtx: vscode.ExtensionContext; constructor(extCtx: vscode.ExtensionContext) { + this.config = new Config(extCtx) this.extCtx = extCtx; } -- cgit v1.2.3