Don't save config when setting w/ non-default source

This commit is contained in:
Max Brunsfeld
2014-12-29 17:08:26 -08:00
parent 57a876e677
commit 637b2b0aba
2 changed files with 6 additions and 1 deletions

View File

@@ -110,6 +110,10 @@ describe "Config", ->
expect(atom.config.save).toHaveBeenCalled()
expect(observeHandler).toHaveBeenCalledWith 42
it "does not save when a non-default 'source' is given", ->
atom.config.set("foo.bar.baz", 42, source: 'some-other-source', scopeSelector: '.a')
expect(atom.config.save).not.toHaveBeenCalled()
it "does not allow a 'source' option without a 'scopeSelector'", ->
expect(-> atom.config.set("foo", 1, source: [".source.ruby"])).toThrow()

View File

@@ -548,6 +548,7 @@ class Config
[keyPath, value, options] = arguments
scopeSelector = options?.scopeSelector
source = options?.source
shouldSave = options?.save ? true
if source and not scopeSelector
throw new Error("::set with a 'source' and no 'sourceSelector' is not yet implemented!")
@@ -565,7 +566,7 @@ class Config
else
@setRawValue(keyPath, value)
@save() unless @configFileHasErrors or options?.save is false
@save() if source is @getUserConfigPath() and shouldSave and not @configFileHasErrors
true
# Essential: Restore the setting at `keyPath` to its default value.