Skip to content

Commit

Permalink
Extension keeps creating the symbols.hidesExplorerArrows key in setti…
Browse files Browse the repository at this point in the history
…ngs (Fixes #232)
  • Loading branch information
miguelsolorio committed Sep 4, 2024
1 parent 16fd3fc commit 69889ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
16 changes: 14 additions & 2 deletions src/lib/change-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@ function monitorConfigChanges() {
const workspaceState = getWorkspaceConfiguration();

const updatedKeys = {};
let hasChanges = false;

for (const currentKey in currentState) {
updatedKeys[currentKey] = workspaceState[currentKey];
if (currentKey in workspaceState) {
if (JSON.stringify(workspaceState[currentKey]) !== JSON.stringify(currentState[currentKey])) {
updatedKeys[currentKey] = workspaceState[currentKey];
hasChanges = true;
}
} else if (currentState[currentKey] !== undefined) {
// The setting was removed, so we need to update it to undefined
updatedKeys[currentKey] = undefined;
hasChanges = true;
}
}

updateConfig(updatedKeys);
if (hasChanges) {
updateConfig(updatedKeys);
}
}

module.exports = {
Expand Down
26 changes: 20 additions & 6 deletions src/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ function getWorkspaceConfiguration() {

const valueGroup = vscode.workspace.getConfiguration("symbols").inspect(PKG_PROP_MAP[key]);

config[PKG_PROP_MAP[key]] = valueGroup.workspaceValue || valueGroup.globalValue || defaultState[PKG_PROP_MAP[key]];
if (valueGroup.workspaceValue !== undefined) {
config[PKG_PROP_MAP[key]] = valueGroup.workspaceValue;
} else if (valueGroup.globalValue !== undefined) {
config[PKG_PROP_MAP[key]] = valueGroup.globalValue;
}
// We no longer fall back to defaultState
}

return config;
Expand Down Expand Up @@ -56,11 +61,20 @@ function updateConfig(config) {
const themeJSON = getSoureFile();

for (const key in config) {
log.info(`symbols.${key} changed, updating to ${config[key]}`);
const updateHandler = updateThemeJSONHandlers[key];
if (updateHandler) {
vscode.workspace.getConfiguration("symbols").update(key, config[key], true);
updateHandler(themeJSON, config[key]);
if (config[key] === undefined) {
log.info(`symbols.${key} removed, updating theme`);
vscode.workspace.getConfiguration("symbols").update(key, undefined, true);
// Remove the key from themeJSON if it exists
if (key in themeJSON) {
delete themeJSON[key];
}
} else {
log.info(`symbols.${key} changed, updating to ${config[key]}`);
const updateHandler = updateThemeJSONHandlers[key];
if (updateHandler) {
vscode.workspace.getConfiguration("symbols").update(key, config[key], true);
updateHandler(themeJSON, config[key]);
}
}
}

Expand Down

0 comments on commit 69889ee

Please sign in to comment.