diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index b1da6a42a..8b637de47 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -173,6 +173,30 @@ describe "Config", -> expect(atom.config.get(['.source.coffee'], 'foo.bar.baz')).toBe 42 expect(atom.config.get(['.source.coffee'], 'foo.bar.ok')).toBe 100 + describe ".getSettings()", -> + it "returns all settings including defaults", -> + atom.config.setDefaults("foo", bar: baz: 10) + atom.config.set("foo.ok", 12) + + expect(atom.config.getSettings().foo).toEqual + ok: 12 + bar: + baz: 10 + + describe "when scoped settings are used", -> + it "returns all the scoped settings including all the defaults", -> + atom.config.setDefaults("foo", bar: baz: 10) + atom.config.set("foo.ok", 12) + atom.config.addScopedSettings("default", ".source.coffee", foo: bar: baz: 42) + atom.config.addScopedSettings("default", ".source.coffee", foo: bar: omg: 'omg') + + expect(atom.config.getSettings(".source.coffee").foo).toEqual + ok: 12 + bar: + baz: 42 + omg: 'omg' + + describe ".pushAtKeyPath(keyPath, value)", -> it "pushes the given value to the array at the key path and updates observers", -> atom.config.set("foo.bar.baz", ["a"]) diff --git a/src/config.coffee b/src/config.coffee index 78ed523ff..b221382bc 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -588,8 +588,14 @@ class Config # Extended: Returns a new {Object} containing all of the global settings and # defaults. This does not include scoped settings. - getSettings: -> - _.deepExtend(@settings, @defaultSettings) + getSettings: (scopeSelector) -> + settings = _.deepExtend(@settings, @defaultSettings) + + if scopeSelector? + scopedSettings = @scopedSettingsStore.propertiesForSelector(scopeSelector) + settings = _.deepExtend(scopedSettings, settings) + + settings # Extended: Get the {String} path to the config file being used. getUserConfigPath: ->