From 9d7f300d87198d734738fd91c00a4db904201007 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Fri, 30 Aug 2024 15:59:29 -0700 Subject: [PATCH] delete configuration properties when empty --- Extension/src/LanguageServer/settingsPanel.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Extension/src/LanguageServer/settingsPanel.ts b/Extension/src/LanguageServer/settingsPanel.ts index 2d0ee5a57d..4522091d02 100644 --- a/Extension/src/LanguageServer/settingsPanel.ts +++ b/Extension/src/LanguageServer/settingsPanel.ts @@ -296,14 +296,17 @@ export class SettingsPanel { } private updateConfig(message: any): void { - const splitEntries: (input: any) => string[] = (input: any) => input.split("\n").filter((e: string) => e); + const splitEntries: (input: any) => string[] | undefined = (input: any) => { + const result = input.split("\n").filter((e: string) => e); + return result.length === 0 ? undefined : result; + }; switch (message.key) { case elementId.configName: this.configValues.name = message.value; break; case elementId.compilerPath: - this.configValues.compilerPath = message.value; + this.configValues.compilerPath = message.value || undefined; break; case elementId.compilerArgs: this.configValues.compilerArgs = splitEntries(message.value); @@ -328,22 +331,22 @@ export class SettingsPanel { this.configValues.cppStandard = message.value; break; case elementId.windowsSdkVersion: - this.configValues.windowsSdkVersion = message.value; + this.configValues.windowsSdkVersion = message.value || undefined; break; case elementId.macFrameworkPath: this.configValues.macFrameworkPath = splitEntries(message.value); break; case elementId.compileCommands: - this.configValues.compileCommands = message.value; + this.configValues.compileCommands = message.value || undefined; break; case elementId.dotConfig: - this.configValues.dotConfig = message.value; + this.configValues.dotConfig = message.value || undefined; break; case elementId.mergeConfigurations: this.configValues.mergeConfigurations = message.value; break; case elementId.configurationProvider: - this.configValues.configurationProvider = message.value; + this.configValues.configurationProvider = message.value || undefined; break; case elementId.forcedInclude: this.configValues.forcedInclude = splitEntries(message.value); @@ -364,7 +367,7 @@ export class SettingsPanel { if (!this.configValues.browse) { this.configValues.browse = {}; } - this.configValues.browse.databaseFilename = message.value; + this.configValues.browse.databaseFilename = message.value || undefined; break; }