mirror of
https://github.com/atom/atom.git
synced 2026-01-24 06:18:03 -05:00
Handle null key-path in Config::set
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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) ->
|
||||
|
||||
Reference in New Issue
Block a user