From 471f9b3701c4f4adef272f1d4abb97aa16fe91cd Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Wed, 8 Jul 2020 13:00:31 -0700 Subject: [PATCH] Fix settings telemetry to handle more deeply nested settings (#5749) --- .../src/LanguageServer/settingsTracker.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Extension/src/LanguageServer/settingsTracker.ts b/Extension/src/LanguageServer/settingsTracker.ts index 50e21a296f..765c39fbad 100644 --- a/Extension/src/LanguageServer/settingsTracker.ts +++ b/Extension/src/LanguageServer/settingsTracker.ts @@ -48,7 +48,13 @@ export class SettingsTracker { if (val === undefined) { continue; } - if (val instanceof Object && !(val instanceof Array)) { + + // Iterate through dotted "sub" settings. + const collectSettingsRecursive = (key: string, val: Object, depth: number) => { + if (depth > 4) { + // Limit settings recursion to 4 dots (not counting the first one in: `C_Cpp.`) + return; + } for (const subKey in val) { const newKey: string = key + "." + subKey; const newRawSetting: any = util.packageJson.contributes.configuration.properties["C_Cpp." + newKey]; @@ -57,11 +63,18 @@ export class SettingsTracker { if (subVal === undefined) { continue; } - const entry: KeyValuePair | undefined = this.filterAndSanitize(newKey, subVal, correctlyScopedSubSettings, filter); - if (entry && entry.key && entry.value) { - result[entry.key] = entry.value; + if (subVal instanceof Object && !(subVal instanceof Array)) { + collectSettingsRecursive(newKey, subVal, depth + 1); + } else { + const entry: KeyValuePair | undefined = this.filterAndSanitize(newKey, subVal, correctlyScopedSubSettings, filter); + if (entry && entry.key && entry.value) { + result[entry.key] = entry.value; + } } } + }; + if (val instanceof Object && !(val instanceof Array)) { + collectSettingsRecursive(key, val, 1); continue; }