diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index 7b7c94c1d..0156855d9 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -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", -> diff --git a/src/config.coffee b/src/config.coffee index 4931994ab..8169b13f2 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -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}.