Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log the modified extension settings as part of Log Diagnostics #12621

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@
"scope": "resource"
},
"C_Cpp.inactiveRegionOpacity": {
"type:": "number",
"type": "number",
"default": 0.55,
"markdownDescription": "%c_cpp.configuration.inactiveRegionOpacity.markdownDescription%",
"scope": "resource",
Expand Down Expand Up @@ -1153,6 +1153,7 @@
"scope": "resource"
},
"C_Cpp.vcFormat.newLine.beforeOpenBrace.lambda": {
"type": "string",
"enum": [
"newLine",
"sameLine",
Expand Down
11 changes: 11 additions & 0 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1948,6 +1948,17 @@ export class DefaultClient implements Client {
if (this.configuration.CurrentConfiguration) {
configJson = `Current Configuration:\n${JSON.stringify(this.configuration.CurrentConfiguration, null, 4)}\n`;
}
const userModifiedSettings = Object.entries(this.settingsTracker.getUserModifiedSettings());
if (userModifiedSettings.length > 0) {
const settings: Record<string, any> = {};
for (const [key] of userModifiedSettings) {
// Some settings were renamed during a telemetry change, so we need to undo that here.
const realKey = key.endsWith('2') ? key.slice(0, key.length - 1) : key;
const fullKey = `C_Cpp.${realKey}`;
settings[fullKey] = vscode.workspace.getConfiguration("C_Cpp").get(realKey) ?? '<error-retrieving-value>';
}
configJson += `Modified Settings:\n${JSON.stringify(settings, null, 4)}\n`;
}

// Get diagnostics for configuration provider info.
let configurationLoggingStr: string = "";
Expand Down
21 changes: 16 additions & 5 deletions Extension/src/LanguageServer/settingsTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ export class SettingsTracker {
if (subVal === undefined) {
continue;
}
if (subVal instanceof Object && !(subVal instanceof Array)) {
if (newRawSetting === undefined && subVal instanceof Object) {
collectSettingsRecursive(newKey, subVal, depth + 1);
} else {
const entry: KeyValuePair | undefined = this.filterAndSanitize(newKey, subVal, correctlyScopedSubSettings, filter);
if (entry && entry.key && entry.value) {
if (entry?.key && entry.value !== undefined) {
result[entry.key] = entry.value;
}
}
}
};
if (val instanceof Object && !(val instanceof Array)) {
if (rawSetting === undefined && val instanceof Object) {
collectSettingsRecursive(key, val, 1);
continue;
}
Expand Down Expand Up @@ -108,6 +108,9 @@ export class SettingsTracker {
return "<invalid>";
}
return val;
} else if (val === curSetting["default"]) {
// C_Cpp.default.browse.path is a special case where the default value is null and doesn't match the type definition.
return val;
}
}
}
Expand All @@ -123,6 +126,9 @@ export class SettingsTracker {
if (typeof value === t) {
return t;
}
if (t === "integer" && typeof value === "number") {
return "number";
}
if (t === "array" && value instanceof Array) {
return t;
}
Expand All @@ -131,8 +137,13 @@ export class SettingsTracker {
}
}
}
} else if (typeof type === "string" && typeof value === type) {
return type;
} else if (typeof type === "string") {
if (typeof value === type) {
return type;
}
if (type === "integer" && typeof value === "number") {
return "number";
}
}
}
return undefined;
Expand Down
Loading