Skip to content

Commit

Permalink
fix(config): update config setting where it currently exists
Browse files Browse the repository at this point in the history
To fix #13 where the filters are determined by the workspace config and not the
global (aka user) config we do update the settings
where its currently found.
This might "copy" more than wanted to e.g. workspace as getConfiguration merges the
settings but we will then persist the full object in the highest order
target/location.

Issue: #13
  • Loading branch information
mbehr1 committed Jan 27, 2021
1 parent d24b304 commit d2a31bd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,19 @@ export function updateConfiguration(section: string, newValue: any) {
// globalValue

try {
console.log(`util.updateConfiguration(section=${section})...`);
const config = vscode.workspace.getConfiguration();
//const curSet = config.inspect(section);
const curSet = config.inspect(section);
//console.log(`curSet.workspaceFolderValue = ${curSet?.workspaceFolderValue}`);
//console.log(`curSet.workspaceValue = ${curSet?.workspaceValue}`);
//console.log(`curSet.globalValue = ${curSet?.globalValue}`);
// todo check which ones exist and add there
// for now add only to globalValue...

return config.update(section, newValue, true);
// check which one exist and add there
// order (highest first): workspaceFolder, workspace, global (, default)
// we don't merge the object (as getConfiguration does)
const target: vscode.ConfigurationTarget = curSet?.workspaceFolderValue !== undefined ? vscode.ConfigurationTarget.WorkspaceFolder : (
curSet?.workspaceValue !== undefined ? vscode.ConfigurationTarget.Workspace : vscode.ConfigurationTarget.Global
);
console.log(`util.updateConfiguration(section=${section}) updating target=${target}`);
return config.update(section, newValue, target);
} catch (err) {
console.error(`err ${err} at updating configuration '${section}'`);
}
Expand Down

0 comments on commit d2a31bd

Please sign in to comment.