Skip to content

Commit

Permalink
Fix settings telemetry to handle more deeply nested settings (#5749)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrow authored Jul 8, 2020
1 parent 196510a commit 471f9b3
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Extension/src/LanguageServer/settingsTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
}

Expand Down

0 comments on commit 471f9b3

Please sign in to comment.