Repository navigation
Improve Config API with regard to scoped settings - #4567
nathansobo wants to merge 5 commits into
Conversation
07288da to
76c9181
Compare
be4b9f6 to
8186613
Compare
|
I've realized that we may want to keep an Config SpecificationConfig settings are organized in a cascade, similar to style sheets. Each entry in the cascade is a hash mapping scope selectors to objects containing key-value pairs of settings. Each entry in the cascade is also associated with a source, which is usually a path to a Sample Cascade:[
{
source: '~/.atom/packages/package-a/settings'
priority: 1
settings:
'atom-workspace':
'foo.enableBar': true
}
{
source: '~/.atom/packages/package-b/settings'
priority: 0.5
settings:
'atom-text-editor':
'foo.enableBaz': false
}
{
source: '~/.atom/config.cson'
priority: -1
settings:
'atom-workspace':
'foo.enableBar': false
}
]Just like in CSS, later entries in the cascade take precedence. The user's settings are associated with a priority of -1 so they always appear last in the cascade. When new entries are added to the cascade, a priority can be specified. If no priority is specified, one will automatically be assigned between 0 and 1 so that the entry becomes the penultimate entry in the cascade just before the user settings. Config Methods
|
Some nits:
|
|
Yeah, I agree with the panel-like priority system. I think the user setting should have priority |
92acba6 to
3c53fcc
Compare
3c53fcc to
c112e4e
Compare
7a5ac7d to
eec6d61
Compare
This reverts commit dc2a453. Conflicts: spec/config-spec.coffee src/config.coffee
There are a few failing specs, but I think they can all be addressed by having a `source` for all properties and using it to target only the user settings in various cases.
Signed-off-by: Nathan Sobo <[email protected]>
eec6d61 to
cffe733
Compare
dd8eda3 to
d1ecafc
Compare
|
This was long ago addressed in other PRs. |
This may be able to supplant #4558.
/cc @maxbrunsfeld: I got the get/set API looking good.
Problems with Config API
The Config API still has some awkwardness leftover from when scoped settings were merged in. It would be nice to make the API more coherent considering the expanded role of settings.
::addScopedSettingsin packages. We need a public equivalent. The main difference is that::addScopedSettingstakes asourceargument. Thesourceis used to distinguish between user settings and package settings internally, so it's important.::isDefault,::restoreDefault, and::getDefaultdon't actually deal with true default values from the schemas. Instead they consider a value "default" if its source isn't the user'sconfig.csonProposed Solution
We can eliminate
::addScopedSettingsand the methods that deal with defaults from the API. Instead, we replace them with the ability to talk about the source of a given setting when getting and setting it. Then the settings view can make decisions based on the source being the user'sconfig.cson, rather than exposing a murky conception of "default" in settings.We propose to replace the following methods:
With these new signatures for get and set
Plus the new
unsetmethod... which can be used to remove a single key path or all key paths from a given scope.If we need to know if a value is assigned in the user's settings, we specify the desired source in our getter. If we get no value back, we can assume we're using some other value (maybe a schema default, mabye from a package). If we want to determine the non-user-assigned value, we exclude it as a source when getting the setting.
Steps
*so they're associated with a source