Support a scopeSelector in getSettings()

This commit is contained in:
Ben Ogle 2014-10-15 16:26:03 -07:00
parent 757abfe3db
commit a42b3ff171
2 changed files with 32 additions and 2 deletions

View File

@ -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"])

View File

@ -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: ->