Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change settings to override defaults #204

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nbelzer
Copy link
Collaborator

@nbelzer nbelzer commented Sep 20, 2020

Resolves #178

Before continuing work on some of the issues that have been created since the release of v2.1 we need this mechanism to introduce new settings without breaking current configurations by users.

From commit 4a4845d:

This commit introduces a method getMergedSettings to the ConfigurationModelProtocol which merges the users settings with the default settings, prioritising the settings set by the user. This allows us to fill up missing settings (say a newly introduced binding) with a default value. This prevents the extension from crashing when a new setting is missing from the user-defined settings. Therefore allowing us to gradually introduce new settings without breaking previous configurations.

This does not touch the users configuration file so there is a potential that this could introduce confusion to the user when a certain binding is introduced but not displayed in their configuration. This should be addressed in #177.

I was not able to introduce tests for the written merging code, this because Xcode does not allow us to test Extension targets. If anyone knows how this works please let me know.


TLDR: This PR introduces a SettingsMerger that recursively merges a dictionary of settings with the default settings, choosing the user defined settings over the default ones in case of a conflict. The extension will now retrieve the configuration by utilising this new merger. This allows us to introduce new settings without breaking current configurations.

This commit introduces a method `getMergedSettings` to the
ConfigurationModelProtocol which merges the users settings with the
default settings, prioritising the settings set by the user. This allows
us to fill up missing settings (say a newly introduced binding) with a
default value. This prevents the extension from crashing when a new
setting is missing from the user-defined settings. Therefore allowing us
to gradually introduce new settings without breaking previous
configurations.

This does not touch the users configuration file so there is a potential
that this could introduce confusion to the user when a certain binding
is introduced but not displayed in their configuration. This should be
addressed in #177.

I was not able to introduce tests for the written merging code, this
because Xcode does not allow us to test Extension targets. If anyone
knows how this works please let me know.
@nbelzer nbelzer self-assigned this Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Override Configuration
1 participant