mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Don't save config when setting w/ non-default source
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user