diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index 189b3daca..b884b3659 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -112,6 +112,13 @@ describe "Config", -> it "does not allow a 'source' option without a 'scopeSelector'", -> expect(-> atom.config.set("foo", 1, source: [".source.ruby"])).toThrow() + describe "when the key-path is null", -> + it "sets the root object", -> + expect(atom.config.set(null, editor: tabLength: 6)).toBe true + expect(atom.config.get("editor.tabLength")).toBe 6 + expect(atom.config.set(null, editor: tabLength: 8, scopeSelector: ['.source.js'])).toBe true + expect(atom.config.get("editor.tabLength", scope: ['.source.js'])).toBe 8 + describe "when the value equals the default value", -> it "does not store the value in the user's config", -> atom.config.setDefaults "foo", diff --git a/src/config.coffee b/src/config.coffee index b237a1e79..a2cc6ad13 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -539,7 +539,7 @@ class Config # * `true` if the value was set. # * `false` if the value was not able to be coerced to the type specified in the setting's schema. set: -> - if arguments[0][0] is '.' + if arguments[0]?[0] is '.' Grim.deprecate """ Passing a scope selector as the first argument to Config::set is deprecated. Pass a `scopeSelector` in an options hash as the final argument instead. @@ -856,7 +856,10 @@ class Config defaultValue = _.valueForKeyPath(@defaultSettings, keyPath) value = undefined if _.isEqual(defaultValue, value) - _.setValueForKeyPath(@settings, keyPath, value) + if keyPath? + _.setValueForKeyPath(@settings, keyPath, value) + else + @settings = value @emitChangeEvent() observeKeyPath: (keyPath, options, callback) ->