Call save() in restoreDefault() for scopedSettings

This commit is contained in:
Ben Ogle
2014-10-20 12:29:46 -07:00
parent 13f81a452d
commit 055c632ee9
2 changed files with 18 additions and 0 deletions

View File

@@ -153,6 +153,14 @@ describe "Config", ->
atom.config.restoreDefault('a.c')
expect(atom.config.get('a.c')).toBeUndefined()
it "calls ::save()", ->
atom.config.setDefaults('a', b: 3)
atom.config.set('a.b', 4)
atom.config.save.reset()
atom.config.restoreDefault('a.c')
expect(atom.config.save.callCount).toBe 1
describe "when scoped settings are used", ->
it "restores the global default when no scoped default set", ->
atom.config.setDefaults("foo", bar: baz: 10)
@@ -173,6 +181,15 @@ describe "Config", ->
expect(atom.config.get(['.source.coffee'], 'foo.bar.baz')).toBe 42
expect(atom.config.get(['.source.coffee'], 'foo.bar.ok')).toBe 100
it "calls ::save()", ->
atom.config.setDefaults("foo", bar: baz: 10)
atom.config.addScopedSettings("default", ".source.coffee", foo: bar: baz: 42)
atom.config.set('.source.coffee', 'foo.bar.baz', 55)
atom.config.save.reset()
atom.config.restoreDefault('.source.coffee', 'foo.bar.baz')
expect(atom.config.save.callCount).toBe 1
describe ".getSettings()", ->
it "returns all settings including defaults", ->
atom.config.setDefaults("foo", bar: baz: 10)

View File

@@ -537,6 +537,7 @@ class Config
@scopedSettingsStore.removePropertiesForSourceAndSelector('user-config', scopeSelector)
_.setValueForKeyPath(settings, keyPath, undefined)
@addScopedSettings('user-config', scopeSelector, settings)
@save() unless @configFileHasErrors
@getDefault(scopeSelector, keyPath)
else
@set(keyPath, _.valueForKeyPath(@defaultSettings, keyPath))