From b6c081a1d5a8a6aec37939eb950a037bb3bb458e Mon Sep 17 00:00:00 2001 From: yoyo930021 Date: Fri, 16 Oct 2020 19:29:15 +0800 Subject: [PATCH] Refactor to setupConfigure for #2388 --- server/src/services/vls.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/server/src/services/vls.ts b/server/src/services/vls.ts index 6ad45fb07a..88a31f1347 100644 --- a/server/src/services/vls.ts +++ b/server/src/services/vls.ts @@ -92,9 +92,7 @@ export class VLS { } async init(params: InitializeParams) { - const config: VLSFullConfig = params.initializationOptions?.config - ? _.merge(getDefaultVLSConfig(), params.initializationOptions.config) - : getDefaultVLSConfig(); + const config: VLSFullConfig = this.getFullConfig(params.initializationOptions?.config); const workspacePath = params.rootPath; if (!workspacePath) { @@ -127,21 +125,26 @@ export class VLS { this.dispose(); }); - this.configure(config); + await this.setupConfigure(config); } listen() { this.lspConnection.listen(); } + private getFullConfig(original: unknown): VLSFullConfig { + return original ? _.merge(getDefaultVLSConfig(), original) : getDefaultVLSConfig(); + } + + public async setupConfigure(config: VLSFullConfig) { + this.configure(config); + + await this.setupDynamicFormatters(config); + } + private setupConfigListeners() { this.lspConnection.onDidChangeConfiguration(async ({ settings }: DidChangeConfigurationParams) => { - if (settings) { - this.configure(settings); - - // onDidChangeConfiguration will fire for Language Server startup - await this.setupDynamicFormatters(settings); - } + await this.setupConfigure(this.getFullConfig(settings)); }); this.documentService.getAllDocuments().forEach(this.triggerValidation);