mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Handle a source but no selector in ::unset
This commit is contained in:
@@ -193,8 +193,14 @@ describe "Config", ->
|
||||
atom.config.unset('a.c')
|
||||
expect(atom.config.save.callCount).toBe 1
|
||||
|
||||
it "throws when called with a source but no scope", ->
|
||||
expect(-> atom.config.unset("a.b", source: "the-source")).toThrow()
|
||||
describe "when a 'source' and no 'scopeSelector' is given", ->
|
||||
it "removes all scoped settings with the given source", ->
|
||||
atom.config.set("foo.bar.baz", 1, scopeSelector: ".a", source: "source-a")
|
||||
atom.config.set("foo.bar.quux", 2, scopeSelector: ".b", source: "source-a")
|
||||
expect(atom.config.get("foo.bar", scope: [".a.b"])).toEqual(baz: 1, quux: 2)
|
||||
|
||||
atom.config.unset(null, source: "source-a")
|
||||
expect(atom.config.get("foo.bar", scope: [".a"])).toEqual(baz: 0, ok: 0)
|
||||
|
||||
describe "when a 'scopeSelector' is given", ->
|
||||
it "restores the global default when no scoped default set", ->
|
||||
|
||||
@@ -585,9 +585,6 @@ class Config
|
||||
else
|
||||
{scopeSelector, source} = options ? {}
|
||||
|
||||
if source and not scopeSelector
|
||||
throw new Error("::unset with a 'source' and no 'sourceSelector' is not yet implemented!")
|
||||
|
||||
source ?= @getUserConfigPath()
|
||||
|
||||
if scopeSelector?
|
||||
@@ -603,7 +600,10 @@ class Config
|
||||
@scopedSettingsStore.removePropertiesForSource(source)
|
||||
@emitChangeEvent()
|
||||
else
|
||||
@set(keyPath, _.valueForKeyPath(@defaultSettings, keyPath))
|
||||
@scopedSettingsStore.removePropertiesForSource(source)
|
||||
if keyPath?
|
||||
@set(keyPath, _.valueForKeyPath(@defaultSettings, keyPath))
|
||||
|
||||
|
||||
# Extended: Get an {Array} of all of the `source` {String}s with which
|
||||
# settings have been added via {::set}.
|
||||
|
||||
Reference in New Issue
Block a user