Skip to content

Commit f077665

Browse files
authored
delete configuration properties when empty (#12670)
1 parent 93a20bc commit f077665

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Extension/src/LanguageServer/settingsPanel.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,17 @@ export class SettingsPanel {
296296
}
297297

298298
private updateConfig(message: any): void {
299-
const splitEntries: (input: any) => string[] = (input: any) => input.split("\n").filter((e: string) => e);
299+
const splitEntries: (input: any) => string[] | undefined = (input: any) => {
300+
const result = input.split("\n").filter((e: string) => e);
301+
return result.length === 0 ? undefined : result;
302+
};
300303

301304
switch (message.key) {
302305
case elementId.configName:
303306
this.configValues.name = message.value;
304307
break;
305308
case elementId.compilerPath:
306-
this.configValues.compilerPath = message.value;
309+
this.configValues.compilerPath = message.value || undefined;
307310
break;
308311
case elementId.compilerArgs:
309312
this.configValues.compilerArgs = splitEntries(message.value);
@@ -328,22 +331,22 @@ export class SettingsPanel {
328331
this.configValues.cppStandard = message.value;
329332
break;
330333
case elementId.windowsSdkVersion:
331-
this.configValues.windowsSdkVersion = message.value;
334+
this.configValues.windowsSdkVersion = message.value || undefined;
332335
break;
333336
case elementId.macFrameworkPath:
334337
this.configValues.macFrameworkPath = splitEntries(message.value);
335338
break;
336339
case elementId.compileCommands:
337-
this.configValues.compileCommands = message.value;
340+
this.configValues.compileCommands = message.value || undefined;
338341
break;
339342
case elementId.dotConfig:
340-
this.configValues.dotConfig = message.value;
343+
this.configValues.dotConfig = message.value || undefined;
341344
break;
342345
case elementId.mergeConfigurations:
343346
this.configValues.mergeConfigurations = message.value;
344347
break;
345348
case elementId.configurationProvider:
346-
this.configValues.configurationProvider = message.value;
349+
this.configValues.configurationProvider = message.value || undefined;
347350
break;
348351
case elementId.forcedInclude:
349352
this.configValues.forcedInclude = splitEntries(message.value);
@@ -364,7 +367,7 @@ export class SettingsPanel {
364367
if (!this.configValues.browse) {
365368
this.configValues.browse = {};
366369
}
367-
this.configValues.browse.databaseFilename = message.value;
370+
this.configValues.browse.databaseFilename = message.value || undefined;
368371
break;
369372
}
370373

0 commit comments

Comments
 (0)