|
|
|
|
@@ -314,11 +314,10 @@ class Config
|
|
|
|
|
@settings = {}
|
|
|
|
|
@scopedSettingsStore = new ScopedPropertyStore
|
|
|
|
|
@usersScopedSettings = new CompositeDisposable
|
|
|
|
|
@usersScopedSettingPriority = {priority: 1000}
|
|
|
|
|
@configFileHasErrors = false
|
|
|
|
|
@configFilePath = fs.resolve(@configDirPath, 'config', ['json', 'cson'])
|
|
|
|
|
@configFilePath ?= path.join(@configDirPath, 'config.cson')
|
|
|
|
|
@prioritiesBySource = {}
|
|
|
|
|
@prioritiesBySource[@getUserConfigPath()] = 1000
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
|
Section: Config Subscription
|
|
|
|
|
@@ -338,36 +337,32 @@ class Config
|
|
|
|
|
# # do stuff with value
|
|
|
|
|
# ```
|
|
|
|
|
#
|
|
|
|
|
# * `scopeDescriptor` (optional) {ScopeDescriptor} describing a path from
|
|
|
|
|
# the root of the syntax tree to a token. Get one by calling
|
|
|
|
|
# {editor.getLastCursor().getScopeDescriptor()}. See {::get} for examples.
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `keyPath` {String} name of the key to observe
|
|
|
|
|
# * `options` {Object}
|
|
|
|
|
# * `scopeDescriptor` (optional) {ScopeDescriptor} describing a path from
|
|
|
|
|
# the root of the syntax tree to a token. Get one by calling
|
|
|
|
|
# {editor.getLastCursor().getScopeDescriptor()}. See {::get} for examples.
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `callback` {Function} to call when the value of the key changes.
|
|
|
|
|
# * `value` the new value of the key
|
|
|
|
|
#
|
|
|
|
|
# Returns a {Disposable} with the following keys on which you can call
|
|
|
|
|
# `.dispose()` to unsubscribe.
|
|
|
|
|
observe: ->
|
|
|
|
|
if arguments.length is 2
|
|
|
|
|
[keyPath, callback] = arguments
|
|
|
|
|
else if arguments.length is 3 and (_.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor)
|
|
|
|
|
Grim.deprecate """
|
|
|
|
|
Passing a scope descriptor as the first argument to Config::observe is deprecated.
|
|
|
|
|
Pass a `scope` in an options hash as the third argument instead.
|
|
|
|
|
"""
|
|
|
|
|
[scopeDescriptor, keyPath, callback] = arguments
|
|
|
|
|
else if arguments.length is 3 and (_.isString(arguments[0]) and _.isObject(arguments[1]))
|
|
|
|
|
[keyPath, options, callback] = arguments
|
|
|
|
|
scopeDescriptor = options.scope
|
|
|
|
|
if options.callNow?
|
|
|
|
|
Grim.deprecate """
|
|
|
|
|
Config::observe no longer takes a `callNow` option. Use ::onDidChange instead.
|
|
|
|
|
Note that ::onDidChange passes its callback different arguments.
|
|
|
|
|
See https://atom.io/docs/api/latest/Config
|
|
|
|
|
"""
|
|
|
|
|
observe: (scopeDescriptor, keyPath, options, callback) ->
|
|
|
|
|
args = Array::slice.call(arguments)
|
|
|
|
|
if args.length is 2
|
|
|
|
|
# observe(keyPath, callback)
|
|
|
|
|
[keyPath, callback, scopeDescriptor, options] = args
|
|
|
|
|
else if args.length is 3 and (Array.isArray(scopeDescriptor) or scopeDescriptor instanceof ScopeDescriptor)
|
|
|
|
|
# observe(scopeDescriptor, keyPath, callback)
|
|
|
|
|
[scopeDescriptor, keyPath, callback, options] = args
|
|
|
|
|
else if args.length is 3 and _.isString(scopeDescriptor) and _.isObject(keyPath)
|
|
|
|
|
# observe(keyPath, options, callback) # Deprecated!
|
|
|
|
|
[keyPath, options, callback, scopeDescriptor] = args
|
|
|
|
|
|
|
|
|
|
message = ""
|
|
|
|
|
message = "`callNow` was set to false. Use ::onDidChange instead. Note that ::onDidChange calls back with different arguments." if options.callNow == false
|
|
|
|
|
Grim.deprecate "Config::observe no longer supports options; see https://atom.io/docs/api/latest/Config. #{message}"
|
|
|
|
|
else
|
|
|
|
|
console.error 'An unsupported form of Config::observe is being used. See https://atom.io/docs/api/latest/Config for details'
|
|
|
|
|
return
|
|
|
|
|
@@ -380,14 +375,13 @@ class Config
|
|
|
|
|
# Essential: Add a listener for changes to a given key path. If `keyPath` is
|
|
|
|
|
# not specified, your callback will be called on changes to any key.
|
|
|
|
|
#
|
|
|
|
|
# * `scopeDescriptor` (optional) {ScopeDescriptor} describing a path from
|
|
|
|
|
# the root of the syntax tree to a token. Get one by calling
|
|
|
|
|
# {editor.getLastCursor().getScopeDescriptor()}. See {::get} for examples.
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `keyPath` (optional) {String} name of the key to observe. Must be
|
|
|
|
|
# specified if `scopeDescriptor` is specified.
|
|
|
|
|
# * `optional` (optional) {Object}
|
|
|
|
|
# * `scopeDescriptor` (optional) {ScopeDescriptor} describing a path from
|
|
|
|
|
# the root of the syntax tree to a token. Get one by calling
|
|
|
|
|
# {editor.getLastCursor().getScopeDescriptor()}. See {::get} for examples.
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `callback` {Function} to call when the value of the key changes.
|
|
|
|
|
# * `event` {Object}
|
|
|
|
|
# * `newValue` the new value of the key
|
|
|
|
|
@@ -396,20 +390,12 @@ class Config
|
|
|
|
|
#
|
|
|
|
|
# Returns a {Disposable} with the following keys on which you can call
|
|
|
|
|
# `.dispose()` to unsubscribe.
|
|
|
|
|
onDidChange: ->
|
|
|
|
|
onDidChange: (scopeDescriptor, keyPath, callback) ->
|
|
|
|
|
args = Array::slice.call(arguments)
|
|
|
|
|
if arguments.length is 1
|
|
|
|
|
[callback] = arguments
|
|
|
|
|
[callback, scopeDescriptor, keyPath] = args
|
|
|
|
|
else if arguments.length is 2
|
|
|
|
|
[keyPath, callback] = arguments
|
|
|
|
|
else if _.isArray(arguments[0]) or arguments[0] instanceof ScopeDescriptor
|
|
|
|
|
Grim.deprecate """
|
|
|
|
|
Passing a scope descriptor as the first argument to Config::onDidChange is deprecated.
|
|
|
|
|
Pass a `scope` in an options hash as the third argument instead.
|
|
|
|
|
"""
|
|
|
|
|
[scopeDescriptor, keyPath, callback] = arguments
|
|
|
|
|
else
|
|
|
|
|
[keyPath, options, callback] = arguments
|
|
|
|
|
scopeDescriptor = options.scope
|
|
|
|
|
[keyPath, callback, scopeDescriptor] = args
|
|
|
|
|
|
|
|
|
|
if scopeDescriptor?
|
|
|
|
|
@onDidChangeScopedKeyPath(scopeDescriptor, keyPath, callback)
|
|
|
|
|
@@ -460,40 +446,24 @@ class Config
|
|
|
|
|
# atom.config.get(scopeDescriptor, 'editor.tabLength') # => 2
|
|
|
|
|
# ```
|
|
|
|
|
#
|
|
|
|
|
# * `scopeDescriptor` (optional) {ScopeDescriptor} describing a path from
|
|
|
|
|
# the root of the syntax tree to a token. Get one by calling
|
|
|
|
|
# {editor.getLastCursor().getScopeDescriptor()}
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `keyPath` The {String} name of the key to retrieve.
|
|
|
|
|
# * `options` (optional) {Object}
|
|
|
|
|
# * `sources` (optional) {Array} of {String} source names. If provided, only
|
|
|
|
|
# values that were associated with these sources during {::set} will be used.
|
|
|
|
|
# * `excludeSources` (optional) {Array} of {String} source names. If provided,
|
|
|
|
|
# values that were associated with these sources during {::set} will not
|
|
|
|
|
# be used.
|
|
|
|
|
# * `scopeDescriptor` (optional) {ScopeDescriptor} describing a path from
|
|
|
|
|
# the root of the syntax tree to a token. Get one by calling
|
|
|
|
|
# {editor.getLastCursor().getScopeDescriptor()}
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
#
|
|
|
|
|
# Returns the value from Atom's default settings, the user's configuration
|
|
|
|
|
# file in the type specified by the configuration schema.
|
|
|
|
|
get: ->
|
|
|
|
|
if arguments.length > 1
|
|
|
|
|
if typeof arguments[0] is 'string' or not arguments[0]?
|
|
|
|
|
[keyPath, options] = arguments
|
|
|
|
|
{scope} = options
|
|
|
|
|
else
|
|
|
|
|
Grim.deprecate """
|
|
|
|
|
Passing a scope descriptor as the first argument to Config::get is deprecated.
|
|
|
|
|
Pass a `scope` in an options hash as the final argument instead.
|
|
|
|
|
"""
|
|
|
|
|
[scope, keyPath] = arguments
|
|
|
|
|
get: (scopeDescriptor, keyPath) ->
|
|
|
|
|
if arguments.length == 1
|
|
|
|
|
# cannot assign to keyPath for the sake of v8 optimization
|
|
|
|
|
globalKeyPath = scopeDescriptor
|
|
|
|
|
@getRawValue(globalKeyPath)
|
|
|
|
|
else
|
|
|
|
|
[keyPath] = arguments
|
|
|
|
|
|
|
|
|
|
if scope?
|
|
|
|
|
value = @getRawScopedValue(scope, keyPath, options)
|
|
|
|
|
value ? @getRawValue(keyPath, options)
|
|
|
|
|
else
|
|
|
|
|
@getRawValue(keyPath, options)
|
|
|
|
|
value = @getRawScopedValue(scopeDescriptor, keyPath)
|
|
|
|
|
value ?= @getRawValue(keyPath)
|
|
|
|
|
value
|
|
|
|
|
|
|
|
|
|
# Essential: Sets the value for a configuration setting.
|
|
|
|
|
#
|
|
|
|
|
@@ -524,95 +494,63 @@ class Config
|
|
|
|
|
# atom.config.get(['source.js'], 'editor.tabLength') # => 4
|
|
|
|
|
# ```
|
|
|
|
|
#
|
|
|
|
|
# * `scopeSelector` (optional) {String}. eg. '.source.ruby'
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `keyPath` The {String} name of the key.
|
|
|
|
|
# * `value` The value of the setting. Passing `undefined` will revert the
|
|
|
|
|
# setting to the default value.
|
|
|
|
|
# * `options` (optional) {Object}
|
|
|
|
|
# * `scopeSelector` (optional) {String}. eg. '.source.ruby'
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `source` (optional) {String} The name of a file with which the setting
|
|
|
|
|
# is associated. Defaults to the user's config file.
|
|
|
|
|
#
|
|
|
|
|
# Returns a {Boolean}
|
|
|
|
|
# * `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 '.'
|
|
|
|
|
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.
|
|
|
|
|
"""
|
|
|
|
|
[scopeSelector, keyPath, value] = arguments
|
|
|
|
|
else
|
|
|
|
|
[keyPath, value, options] = arguments
|
|
|
|
|
scopeSelector = options?.scopeSelector
|
|
|
|
|
source = options?.source
|
|
|
|
|
set: (scopeSelector, keyPath, value) ->
|
|
|
|
|
if arguments.length < 3
|
|
|
|
|
value = keyPath
|
|
|
|
|
keyPath = scopeSelector
|
|
|
|
|
scopeSelector = undefined
|
|
|
|
|
|
|
|
|
|
if source and not scopeSelector
|
|
|
|
|
throw new Error("::set with a 'source' and no 'sourceSelector' is not yet implemented!")
|
|
|
|
|
|
|
|
|
|
source ?= @getUserConfigPath()
|
|
|
|
|
|
|
|
|
|
unless value is undefined
|
|
|
|
|
unless value == undefined
|
|
|
|
|
try
|
|
|
|
|
value = @makeValueConformToSchema(keyPath, value)
|
|
|
|
|
catch e
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
if scopeSelector?
|
|
|
|
|
@setRawScopedValue(source, scopeSelector, keyPath, value)
|
|
|
|
|
@setRawScopedValue(scopeSelector, keyPath, value)
|
|
|
|
|
else
|
|
|
|
|
@setRawValue(keyPath, value)
|
|
|
|
|
|
|
|
|
|
@save() unless @configFileHasErrors
|
|
|
|
|
true
|
|
|
|
|
|
|
|
|
|
# Essential: Restore the setting at `keyPath` to its default value.
|
|
|
|
|
# Extended: Restore the global setting at `keyPath` to its default value.
|
|
|
|
|
#
|
|
|
|
|
# * `scopeSelector` (optional) {String}. eg. '.source.ruby'
|
|
|
|
|
# See [the scopes docs](https://atom.io/docs/latest/advanced/scopes-and-scope-descriptors)
|
|
|
|
|
# for more information.
|
|
|
|
|
# * `keyPath` The {String} name of the key.
|
|
|
|
|
# * `options` (optional) {Object}
|
|
|
|
|
# * `scopeSelector` (optional) {String}. See {::set}
|
|
|
|
|
# * `source` (optional) {String}. See {::set}
|
|
|
|
|
unset: (keyPath, options) ->
|
|
|
|
|
if typeof options is 'string'
|
|
|
|
|
Grim.deprecate """
|
|
|
|
|
Passing a scope selector as the first argument to Config::unset is deprecated.
|
|
|
|
|
Pass a `scopeSelector` in an options hash as the second argument instead.
|
|
|
|
|
"""
|
|
|
|
|
scopeSelector = keyPath
|
|
|
|
|
keyPath = options
|
|
|
|
|
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?
|
|
|
|
|
if keyPath?
|
|
|
|
|
settings = @scopedSettingsStore.propertiesForSourceAndSelector(source, scopeSelector)
|
|
|
|
|
if _.valueForKeyPath(settings, keyPath)?
|
|
|
|
|
@scopedSettingsStore.removePropertiesForSourceAndSelector(source, scopeSelector)
|
|
|
|
|
_.setValueForKeyPath(settings, keyPath, undefined)
|
|
|
|
|
settings = withoutEmptyObjects(settings)
|
|
|
|
|
@addScopedSettings(source, scopeSelector, settings, priority: @usersScopedSettingPriority) if settings?
|
|
|
|
|
@save() unless @configFileHasErrors
|
|
|
|
|
else
|
|
|
|
|
@scopedSettingsStore.removePropertiesForSource(source)
|
|
|
|
|
else
|
|
|
|
|
@set(keyPath, _.valueForKeyPath(@defaultSettings, keyPath))
|
|
|
|
|
|
|
|
|
|
# Deprecated: Restore the global setting at `keyPath` to its default value.
|
|
|
|
|
#
|
|
|
|
|
# Returns the new value.
|
|
|
|
|
restoreDefault: (scopeSelector, keyPath) ->
|
|
|
|
|
Grim.deprecate("Use ::unset instead.")
|
|
|
|
|
@unset(scopeSelector, keyPath)
|
|
|
|
|
@get(keyPath)
|
|
|
|
|
if arguments.length == 1
|
|
|
|
|
keyPath = scopeSelector
|
|
|
|
|
scopeSelector = null
|
|
|
|
|
|
|
|
|
|
# Deprecated: Get the global default value of the key path. _Please note_ that in most
|
|
|
|
|
if scopeSelector?
|
|
|
|
|
settings = @scopedSettingsStore.propertiesForSourceAndSelector('user-config', scopeSelector)
|
|
|
|
|
if _.valueForKeyPath(settings, keyPath)?
|
|
|
|
|
@scopedSettingsStore.removePropertiesForSourceAndSelector('user-config', scopeSelector)
|
|
|
|
|
_.setValueForKeyPath(settings, keyPath, undefined)
|
|
|
|
|
settings = withoutEmptyObjects(settings)
|
|
|
|
|
@addScopedSettings('user-config', scopeSelector, settings, @usersScopedSettingPriority) if settings?
|
|
|
|
|
@save() unless @configFileHasErrors
|
|
|
|
|
@getDefault(scopeSelector, keyPath)
|
|
|
|
|
else
|
|
|
|
|
@set(keyPath, _.valueForKeyPath(@defaultSettings, keyPath))
|
|
|
|
|
@get(keyPath)
|
|
|
|
|
|
|
|
|
|
# Extended: Get the global default value of the key path. _Please note_ that in most
|
|
|
|
|
# cases calling this is not necessary! {::get} returns the default value when
|
|
|
|
|
# a custom value is not specified.
|
|
|
|
|
#
|
|
|
|
|
@@ -620,30 +558,35 @@ class Config
|
|
|
|
|
# * `keyPath` The {String} name of the key.
|
|
|
|
|
#
|
|
|
|
|
# Returns the default value.
|
|
|
|
|
getDefault: ->
|
|
|
|
|
Grim.deprecate("Use `::get(keyPath, {scope, excludeSources: [atom.config.getUserConfigPath()]})` instead")
|
|
|
|
|
if arguments.length is 1
|
|
|
|
|
[keyPath] = arguments
|
|
|
|
|
else
|
|
|
|
|
[scopeSelector, keyPath] = arguments
|
|
|
|
|
scope = [scopeSelector]
|
|
|
|
|
@get(keyPath, {scope, excludeSources: [@getUserConfigPath()]})
|
|
|
|
|
getDefault: (scopeSelector, keyPath) ->
|
|
|
|
|
if arguments.length == 1
|
|
|
|
|
keyPath = scopeSelector
|
|
|
|
|
scopeSelector = null
|
|
|
|
|
|
|
|
|
|
# Deprecated: Is the value at `keyPath` its default value?
|
|
|
|
|
if scopeSelector?
|
|
|
|
|
defaultValue = @scopedSettingsStore.getPropertyValue(scopeSelector, keyPath, excludeSources: ['user-config'])
|
|
|
|
|
defaultValue ?= _.valueForKeyPath(@defaultSettings, keyPath)
|
|
|
|
|
else
|
|
|
|
|
defaultValue = _.valueForKeyPath(@defaultSettings, keyPath)
|
|
|
|
|
_.deepClone(defaultValue)
|
|
|
|
|
|
|
|
|
|
# Extended: Is the value at `keyPath` its default value?
|
|
|
|
|
#
|
|
|
|
|
# * `scopeSelector` (optional) {String}. eg. '.source.ruby'
|
|
|
|
|
# * `keyPath` The {String} name of the key.
|
|
|
|
|
#
|
|
|
|
|
# Returns a {Boolean}, `true` if the current value is the default, `false`
|
|
|
|
|
# otherwise.
|
|
|
|
|
isDefault: ->
|
|
|
|
|
Grim.deprecate("Use `not ::get(keyPath, {scope, sources: [atom.config.getUserConfigPath()]})?` instead")
|
|
|
|
|
if arguments.length is 1
|
|
|
|
|
[keyPath] = arguments
|
|
|
|
|
isDefault: (scopeSelector, keyPath) ->
|
|
|
|
|
if arguments.length == 1
|
|
|
|
|
keyPath = scopeSelector
|
|
|
|
|
scopeSelector = null
|
|
|
|
|
|
|
|
|
|
if scopeSelector?
|
|
|
|
|
settings = @scopedSettingsStore.propertiesForSourceAndSelector('user-config', scopeSelector)
|
|
|
|
|
not _.valueForKeyPath(settings, keyPath)?
|
|
|
|
|
else
|
|
|
|
|
[scopeSelector, keyPath] = arguments
|
|
|
|
|
scope = [scopeSelector]
|
|
|
|
|
not @get(keyPath, {scope, sources: [@getUserConfigPath()]})?
|
|
|
|
|
not _.valueForKeyPath(@settings, keyPath)?
|
|
|
|
|
|
|
|
|
|
# Extended: Retrieve the schema for a specific key path. The schema will tell
|
|
|
|
|
# you what type the keyPath expects, and other metadata about the config
|
|
|
|
|
@@ -796,7 +739,7 @@ class Config
|
|
|
|
|
|
|
|
|
|
save: ->
|
|
|
|
|
allSettings = global: @settings
|
|
|
|
|
allSettings = _.extend allSettings, @scopedSettingsStore.propertiesForSource(@getUserConfigPath())
|
|
|
|
|
allSettings = _.extend allSettings, @scopedSettingsStore.propertiesForSource('user-config')
|
|
|
|
|
CSON.writeFileSync(@configFilePath, allSettings)
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
|
@@ -841,11 +784,9 @@ class Config
|
|
|
|
|
catch e
|
|
|
|
|
console.warn("'#{keyPath}' could not be set. Attempted value: #{JSON.stringify(value)}; Schema: #{JSON.stringify(@getSchema(keyPath))}")
|
|
|
|
|
|
|
|
|
|
getRawValue: (keyPath, options) ->
|
|
|
|
|
unless options?.excludeSources?.indexOf(@getUserConfigPath()) >= 0
|
|
|
|
|
value = _.valueForKeyPath(@settings, keyPath)
|
|
|
|
|
unless options?.sources?.length > 0
|
|
|
|
|
defaultValue = _.valueForKeyPath(@defaultSettings, keyPath)
|
|
|
|
|
getRawValue: (keyPath) ->
|
|
|
|
|
value = _.valueForKeyPath(@settings, keyPath)
|
|
|
|
|
defaultValue = _.valueForKeyPath(@defaultSettings, keyPath)
|
|
|
|
|
|
|
|
|
|
if value?
|
|
|
|
|
value = _.deepClone(value)
|
|
|
|
|
@@ -944,7 +885,7 @@ class Config
|
|
|
|
|
resetUserScopedSettings: (newScopedSettings) ->
|
|
|
|
|
@usersScopedSettings?.dispose()
|
|
|
|
|
@usersScopedSettings = new CompositeDisposable
|
|
|
|
|
@usersScopedSettings.add @scopedSettingsStore.addProperties(@getUserConfigPath(), newScopedSettings, priority: @prioritiesBySource[@getUserConfigPath()])
|
|
|
|
|
@usersScopedSettings.add @scopedSettingsStore.addProperties('user-config', newScopedSettings, @usersScopedSettingPriority)
|
|
|
|
|
@emitter.emit 'did-change'
|
|
|
|
|
|
|
|
|
|
addScopedSettings: (source, selector, value, options) ->
|
|
|
|
|
@@ -956,7 +897,7 @@ class Config
|
|
|
|
|
disposable.dispose()
|
|
|
|
|
@emitter.emit 'did-change'
|
|
|
|
|
|
|
|
|
|
setRawScopedValue: (source, selector, keyPath, value) ->
|
|
|
|
|
setRawScopedValue: (selector, keyPath, value) ->
|
|
|
|
|
if keyPath?
|
|
|
|
|
newValue = {}
|
|
|
|
|
_.setValueForKeyPath(newValue, keyPath, value)
|
|
|
|
|
@@ -964,29 +905,29 @@ class Config
|
|
|
|
|
|
|
|
|
|
settingsBySelector = {}
|
|
|
|
|
settingsBySelector[selector] = value
|
|
|
|
|
@usersScopedSettings.add @scopedSettingsStore.addProperties(source, settingsBySelector, priority: @prioritiesBySource[source])
|
|
|
|
|
@usersScopedSettings.add @scopedSettingsStore.addProperties('user-config', settingsBySelector, @usersScopedSettingPriority)
|
|
|
|
|
@emitter.emit 'did-change'
|
|
|
|
|
|
|
|
|
|
getRawScopedValue: (scopeDescriptor, keyPath, options) ->
|
|
|
|
|
getRawScopedValue: (scopeDescriptor, keyPath) ->
|
|
|
|
|
scopeDescriptor = ScopeDescriptor.fromObject(scopeDescriptor)
|
|
|
|
|
@scopedSettingsStore.getPropertyValue(scopeDescriptor.getScopeChain(), keyPath, options)
|
|
|
|
|
@scopedSettingsStore.getPropertyValue(scopeDescriptor.getScopeChain(), keyPath)
|
|
|
|
|
|
|
|
|
|
observeScopedKeyPath: (scope, keyPath, callback) ->
|
|
|
|
|
oldValue = @get(keyPath, {scope})
|
|
|
|
|
observeScopedKeyPath: (scopeDescriptor, keyPath, callback) ->
|
|
|
|
|
oldValue = @get(scopeDescriptor, keyPath)
|
|
|
|
|
|
|
|
|
|
callback(oldValue)
|
|
|
|
|
|
|
|
|
|
didChange = =>
|
|
|
|
|
newValue = @get(keyPath, {scope})
|
|
|
|
|
newValue = @get(scopeDescriptor, keyPath)
|
|
|
|
|
callback(newValue) unless _.isEqual(oldValue, newValue)
|
|
|
|
|
oldValue = newValue
|
|
|
|
|
|
|
|
|
|
@emitter.on 'did-change', didChange
|
|
|
|
|
|
|
|
|
|
onDidChangeScopedKeyPath: (scope, keyPath, callback) ->
|
|
|
|
|
oldValue = @get(keyPath, {scope})
|
|
|
|
|
onDidChangeScopedKeyPath: (scopeDescriptor, keyPath, callback) ->
|
|
|
|
|
oldValue = @get(scopeDescriptor, keyPath)
|
|
|
|
|
didChange = =>
|
|
|
|
|
newValue = @get(keyPath, {scope})
|
|
|
|
|
newValue = @get(scopeDescriptor, keyPath)
|
|
|
|
|
callback({oldValue, newValue, keyPath}) unless _.isEqual(oldValue, newValue)
|
|
|
|
|
oldValue = newValue
|
|
|
|
|
|
|
|
|
|
|