Adhere to the schemas when loading the user’s config

This commit is contained in:
Ben Ogle
2015-01-27 15:34:44 -08:00
parent 79094ee889
commit b9b2b4bca2
2 changed files with 32 additions and 1 deletions

View File

@@ -1032,8 +1032,19 @@ class Config
resetUserScopedSettings: (newScopedSettings) ->
source = @getUserConfigPath()
priority = @priorityForSource(source)
@scopedSettingsStore.removePropertiesForSource(source)
@scopedSettingsStore.addProperties(source, newScopedSettings, priority: @priorityForSource(source))
for scopeSelector, settings of newScopedSettings
validatedSettings = {}
try
settings = withoutEmptyObjects(@makeValueConformToSchema(null, settings))
validatedSettings[scopeSelector] = settings
catch e
;
@scopedSettingsStore.addProperties(source, validatedSettings, {priority}) if validatedSettings[scopeSelector]
@emitChangeEvent()
addScopedSettings: (source, selector, value, options) ->