alterNERDtive-base: fixed config change handling
This commit is contained in:
parent
afee22cf62
commit
9637975bdb
1 changed files with 6 additions and 4 deletions
|
@ -260,14 +260,16 @@ namespace alterNERDtive
|
||||||
string name = match.Groups["name"].Value;
|
string name = match.Groups["name"].Value;
|
||||||
Log.Debug($"Configuration has changed, '{id}.{name}': '{from}' → '{to}'");
|
Log.Debug($"Configuration has changed, '{id}.{name}': '{from}' → '{to}'");
|
||||||
|
|
||||||
|
Configuration.Option o = Config.GetOption(id, name);
|
||||||
// When loaded from profile but not explicitly set, will be null.
|
// When loaded from profile but not explicitly set, will be null.
|
||||||
// Then load default.
|
// Then load default.
|
||||||
// Same applies to resetting a saved option (= saving null to the profile).
|
// Same applies to resetting a saved option (= saving null to the profile).
|
||||||
_ = to ?? Config.ApplyDefault(id, name);
|
if (to == null)
|
||||||
|
{
|
||||||
|
_ = to ?? Config.ApplyDefault(id, name);
|
||||||
|
}
|
||||||
// When not null, check if there’s a constraint on valid values.
|
// When not null, check if there’s a constraint on valid values.
|
||||||
Configuration.Option o = Config.GetOption(id, name);
|
else if (o.ValidValues != null && !o.ValidValues.Contains(to))
|
||||||
if (o.ValidValues != null && !o.ValidValues.Contains(to))
|
|
||||||
{
|
{
|
||||||
Log.Error($@"Invalid value ""{to}"" for option ""{id}.{option}"", reverting to default …");
|
Log.Error($@"Invalid value ""{to}"" for option ""{id}.{option}"", reverting to default …");
|
||||||
Config.ApplyDefault(id, name);
|
Config.ApplyDefault(id, name);
|
||||||
|
|
Loading…
Reference in a new issue