From 637b2b0ababaa6576a878f59998dec4445f2b450 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 29 Dec 2014 17:08:26 -0800 Subject: [PATCH] Don't save config when setting w/ non-default source --- spec/config-spec.coffee | 4 ++++ src/config.coffee | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) 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.