Skip to content

Commit

Permalink
Fix C_Cpp.default.configurationProvider changes not taking effect. (#…
Browse files Browse the repository at this point in the history
…5043)

* Fix C_Cpp.default.configurationProvider changes not taking effect.
  • Loading branch information
sean-mcmanus authored Mar 3, 2020
1 parent dfe7ff3 commit e52fdd5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion Extension/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ module.exports = {
"typedef": [
true,
"variable-declaration",
"call-signature"
"call-signature",
"variable-declaration-ignore-function"
],
"whitespace": [
true,
Expand Down
2 changes: 1 addition & 1 deletion Extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
* Don't show `includePath` code actions if compile commands or custom configuration providers are used. [#2334](https://github.com/Microsoft/vscode-cpptools/issues/2334)
* Fix `C_Cpp.clang_format_path` not accepting environment variables. [#2344](https://github.com/Microsoft/vscode-cpptools/issues/2344)
* Fix IntelliSense not working with non-ASCII characters in the WSL install path. [#2351](https://github.com/Microsoft/vscode-cpptools/issues/2351)
* Filter out buggy IntelliSense error `"= delete" can only appear on the first declaration of a function`. [#2352](https://github.com/Microsoft/vscode-cpptools/issues/2352)
* Filter out incorrect IntelliSense error `"= delete" can only appear on the first declaration of a function`. [#2352](https://github.com/Microsoft/vscode-cpptools/issues/2352)
* Fix IntelliSense failing with WSL if gcc is installed bug g++ isn't. [#2360](https://github.com/Microsoft/vscode-cpptools/issues/2360)
* Fix WSL paths starting with `/mnt/` failing to get symbols parsed. [#2361](https://github.com/Microsoft/vscode-cpptools/issues/2361)
* Fix IntelliSense process crash when hovering over a designated initializer list with an anonymous struct. [#2370](https://github.com/Microsoft/vscode-cpptools/issues/2370)
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ function onDidChangeTextEditorSelection(event: vscode.TextEditorSelectionChangeE
}

if (activeDocument !== event.textEditor.document.uri.toString()) {
// For some strange (buggy?) reason we don't reliably get onDidChangeActiveTextEditor callbacks.
// For some unknown reason we don't reliably get onDidChangeActiveTextEditor callbacks.
activeDocument = event.textEditor.document.uri.toString();
clients.activeDocumentChanged(event.textEditor.document);
ui.activeDocumentChanged();
Expand Down
2 changes: 1 addition & 1 deletion Extension/src/LanguageServer/persistentState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class PersistentWorkspaceState<T> extends PersistentStateBase<T> {

export class PersistentFolderState<T> extends PersistentWorkspaceState<T> {
constructor(key: string, defaultValue: T, folder: vscode.WorkspaceFolder) {
// Check for the old (buggy) key. If found, remove it and update the new key with the old value.
// Check for the old key. If found, remove it and update the new key with the old value.
let old_key: string = key + (folder ? `-${path.basename(folder.uri.fsPath)}` : "-untitled");
let old_val: T;
if (util.extensionContext) {
Expand Down
29 changes: 15 additions & 14 deletions Extension/src/LanguageServer/settingsTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,37 @@ export class SettingsTracker {
}

private collectSettings(filter: FilterFunction): { [key: string]: string } {
let settingsResourceScope: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", this.resource);
let settingsNonScoped: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp");
const settingsResourceScope: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp", this.resource);
const settingsNonScoped: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("C_Cpp");
const selectCorrectlyScopedSettings = (rawSetting: any): vscode.WorkspaceConfiguration =>
(!rawSetting || rawSetting.scope === "resource" || rawSetting.scope === "machine-overridable") ? settingsResourceScope : settingsNonScoped;
let result: { [key: string]: string } = {};

for (let key in settingsResourceScope) {
let curSetting: any = util.packageJson.contributes.configuration.properties["C_Cpp." + key];
if (curSetting === undefined) {
continue;
}
let settings: vscode.WorkspaceConfiguration = (curSetting.scope === "resource" || curSetting.scope === "machine-overridable") ? settingsResourceScope : settingsNonScoped;
let val: any = this.getSetting(settings, key);
for (const key in settingsResourceScope) {
const rawSetting: any = util.packageJson.contributes.configuration.properties["C_Cpp." + key];
const correctlyScopedSettings: vscode.WorkspaceConfiguration = selectCorrectlyScopedSettings(rawSetting);
const val: any = this.getSetting(correctlyScopedSettings, key);
if (val === undefined) {
continue;
}
if (val instanceof Object && !(val instanceof Array)) {
for (let subKey in val) {
let newKey: string = key + "." + subKey;
let subVal: any = this.getSetting(settings, newKey);
for (const subKey in val) {
const newKey: string = key + "." + subKey;
const newRawSetting: any = util.packageJson.contributes.configuration.properties["C_Cpp." + newKey];
const correctlyScopedSubSettings: vscode.WorkspaceConfiguration = selectCorrectlyScopedSettings(newRawSetting);
const subVal: any = this.getSetting(correctlyScopedSubSettings, newKey);
if (subVal === undefined) {
continue;
}
let entry: KeyValuePair = this.filterAndSanitize(newKey, subVal, settings, filter);
const entry: KeyValuePair = this.filterAndSanitize(newKey, subVal, correctlyScopedSubSettings, filter);
if (entry && entry.key && entry.value) {
result[entry.key] = entry.value;
}
}
continue;
}

let entry: KeyValuePair = this.filterAndSanitize(key, val, settings, filter);
const entry: KeyValuePair = this.filterAndSanitize(key, val, correctlyScopedSettings, filter);
if (entry && entry.key && entry.value) {
result[entry.key] = entry.value;
}
Expand Down

0 comments on commit e52fdd5

Please sign in to comment.