Skip to content

Commit e5ce40b

Browse files
authored
Log the modified extension settings as part of Log Diagnostics (#12621)
1 parent d3cd4fc commit e5ce40b

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

Extension/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@
610610
"scope": "resource"
611611
},
612612
"C_Cpp.inactiveRegionOpacity": {
613-
"type:": "number",
613+
"type": "number",
614614
"default": 0.55,
615615
"markdownDescription": "%c_cpp.configuration.inactiveRegionOpacity.markdownDescription%",
616616
"scope": "resource",
@@ -1153,6 +1153,7 @@
11531153
"scope": "resource"
11541154
},
11551155
"C_Cpp.vcFormat.newLine.beforeOpenBrace.lambda": {
1156+
"type": "string",
11561157
"enum": [
11571158
"newLine",
11581159
"sameLine",

Extension/src/LanguageServer/client.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,17 @@ export class DefaultClient implements Client {
19481948
if (this.configuration.CurrentConfiguration) {
19491949
configJson = `Current Configuration:\n${JSON.stringify(this.configuration.CurrentConfiguration, null, 4)}\n`;
19501950
}
1951+
const userModifiedSettings = Object.entries(this.settingsTracker.getUserModifiedSettings());
1952+
if (userModifiedSettings.length > 0) {
1953+
const settings: Record<string, any> = {};
1954+
for (const [key] of userModifiedSettings) {
1955+
// Some settings were renamed during a telemetry change, so we need to undo that here.
1956+
const realKey = key.endsWith('2') ? key.slice(0, key.length - 1) : key;
1957+
const fullKey = `C_Cpp.${realKey}`;
1958+
settings[fullKey] = vscode.workspace.getConfiguration("C_Cpp").get(realKey) ?? '<error-retrieving-value>';
1959+
}
1960+
configJson += `Modified Settings:\n${JSON.stringify(settings, null, 4)}\n`;
1961+
}
19511962

19521963
// Get diagnostics for configuration provider info.
19531964
let configurationLoggingStr: string = "";

Extension/src/LanguageServer/settingsTracker.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,17 @@ export class SettingsTracker {
6262
if (subVal === undefined) {
6363
continue;
6464
}
65-
if (subVal instanceof Object && !(subVal instanceof Array)) {
65+
if (newRawSetting === undefined && subVal instanceof Object) {
6666
collectSettingsRecursive(newKey, subVal, depth + 1);
6767
} else {
6868
const entry: KeyValuePair | undefined = this.filterAndSanitize(newKey, subVal, correctlyScopedSubSettings, filter);
69-
if (entry && entry.key && entry.value) {
69+
if (entry?.key && entry.value !== undefined) {
7070
result[entry.key] = entry.value;
7171
}
7272
}
7373
}
7474
};
75-
if (val instanceof Object && !(val instanceof Array)) {
75+
if (rawSetting === undefined && val instanceof Object) {
7676
collectSettingsRecursive(key, val, 1);
7777
continue;
7878
}
@@ -108,6 +108,9 @@ export class SettingsTracker {
108108
return "<invalid>";
109109
}
110110
return val;
111+
} else if (val === curSetting["default"]) {
112+
// C_Cpp.default.browse.path is a special case where the default value is null and doesn't match the type definition.
113+
return val;
111114
}
112115
}
113116
}
@@ -123,6 +126,9 @@ export class SettingsTracker {
123126
if (typeof value === t) {
124127
return t;
125128
}
129+
if (t === "integer" && typeof value === "number") {
130+
return "number";
131+
}
126132
if (t === "array" && value instanceof Array) {
127133
return t;
128134
}
@@ -131,8 +137,13 @@ export class SettingsTracker {
131137
}
132138
}
133139
}
134-
} else if (typeof type === "string" && typeof value === type) {
135-
return type;
140+
} else if (typeof type === "string") {
141+
if (typeof value === type) {
142+
return type;
143+
}
144+
if (type === "integer" && typeof value === "number") {
145+
return "number";
146+
}
136147
}
137148
}
138149
return undefined;

0 commit comments

Comments
 (0)