mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Reset all user config values when the schema changes.
This commit is contained in:
@@ -797,6 +797,7 @@ class Config
|
||||
_.extend rootSchema, schema
|
||||
@setDefaults(keyPath, @extractDefaultsFromSchema(schema))
|
||||
@setScopedDefaultsFromSchema(keyPath, schema)
|
||||
@resetForSchemaChange()
|
||||
|
||||
load: ->
|
||||
@initializeConfigDirectory()
|
||||
@@ -1002,6 +1003,20 @@ class Config
|
||||
value = @constructor.executeSchemaEnforcers(keyPath, value, schema) if schema = @getSchema(keyPath)
|
||||
value
|
||||
|
||||
# When the schema is changed / added, there may be values set in the config
|
||||
# that do not conform to the config. This will reset make them conform.
|
||||
resetForSchemaChange: (source=@getUserConfigPath()) ->
|
||||
settings = @settings
|
||||
@settings = null
|
||||
@set(null, settings, {save: false})
|
||||
|
||||
priority = @priorityForSource(source)
|
||||
selectorsAndSettings = @scopedSettingsStore.propertiesForSource(source)
|
||||
@scopedSettingsStore.removePropertiesForSource(source)
|
||||
for scopeSelector, settings of selectorsAndSettings
|
||||
@set(null, settings, {scopeSelector, source, priority, save: false}) if settings?
|
||||
return
|
||||
|
||||
###
|
||||
Section: Private Scoped Settings
|
||||
###
|
||||
|
||||
Reference in New Issue
Block a user