diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index 0156855d9..31e4f70bc 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -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() diff --git a/src/config.coffee b/src/config.coffee index 8169b13f2..ef2847015 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -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.