Skip to content

Commit

Permalink
Update settings configuration logic (#241)
Browse files Browse the repository at this point in the history
* Revert 69889ee

* Don't update user settings
  • Loading branch information
miguelsolorio authored Sep 9, 2024
1 parent e4bc1fb commit eb09d7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
16 changes: 2 additions & 14 deletions src/lib/change-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,12 @@ function monitorConfigChanges() {
const workspaceState = getWorkspaceConfiguration();

const updatedKeys = {};
let hasChanges = false;

for (const currentKey in currentState) {
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;
}
updatedKeys[currentKey] = workspaceState[currentKey];
}

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

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

const valueGroup = vscode.workspace.getConfiguration("symbols").inspect(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
config[PKG_PROP_MAP[key]] = valueGroup.workspaceValue || valueGroup.globalValue || defaultState[PKG_PROP_MAP[key]];
}

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

for (const key in config) {
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]);
}
log.info(`🤖 symbols.${key} changed, updating to ${config[key]}`);
const updateHandler = updateThemeJSONHandlers[key];
if (updateHandler) {
updateHandler(themeJSON, config[key]);
}
}

Expand Down

0 comments on commit eb09d7b

Please sign in to comment.