Enable/Disable Hex mode button: modify setting in existing location#1109
Enable/Disable Hex mode button: modify setting in existing location#1109haneefdm merged 2 commits intoMarus:masterfrom
Conversation
This button toggles the `cortex-debug.variableUseNaturalFormat` setting. Its value can come from the `settings.json` for the current User, Workspace, or Workspace Folder. If it is set in any of those places, modify it there. Otherwise, modify it in the User's global `settings.json`. Fixes Marus#1107
|
I tested the basic functionality for this, and it worked great to select between workspace and user settings, and default to user settings if the option is unset everywhere. I wasn't able to test the language-specific override functionality, because this particular setting doesn't seem to pull in language overrides -- at least from diff --git a/src/frontend/extension.ts b/src/frontend/extension.ts
index 6d08c7c..01c8337 100644
--- a/src/frontend/extension.ts
+++ b/src/frontend/extension.ts
@@ -336,22 +336,13 @@ export class CortexDebugExtension {
['workspaceFolderValue', vscode.ConfigurationTarget.WorkspaceFolde>
['workspaceValue', vscode.ConfigurationTarget.Workspace],
['globalValue', vscode.ConfigurationTarget.Global],
- // Modify user settings if setting isn't configured yet
- ['defaultValue', vscode.ConfigurationTarget.Global],
];
const info = config.inspect(section);
for (const mapping of configurationTargetMapping) {
const [inspectKey, mappingTarget] = mapping;
- const inspectLanguageKey = inspectKey.replace('Value', 'LanguageVa>
- if (info[inspectLanguageKey] !== undefined)
- return [mappingTarget, true];
if (info[inspectKey] !== undefined)
return [mappingTarget, false];
}
- // Shouldn't get here unless new configuration targets get added to the
- // VSCode API, only those sources have values for this setting, and th>
- // setting doesn't have a default value. Still, do something rational
- // just in case.
return [vscode.ConfigurationTarget.Global, false];
}
|
The order is specified in https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration and has language overrides from all sources taking precedence over non-overridden settings from every source.
4965db0 to
bad9717
Compare
|
Sorry for the flurry of updates. I noticed after creating the PR that my precedence order didn't match the API documentation. Should be all set to go now. |
|
Thank you! I appreciate your openness to my pull requests. I really like cortex-debug and its related projects, and I'm enjoying playing a small part in improving them. |
This button toggles the
cortex-debug.variableUseNaturalFormatsetting. Its value can come from thesettings.jsonfor the current User, Workspace, or Workspace Folder. If it is set in any of those places, modify it there. Otherwise, modify it in the User's globalsettings.json.Fixes #1107