atom/atom — pull request #3847 by benogle (2014-10-16 01:03:52+00:00)
Title: Add scoped defaults

The settings view needs to know if a given scoped property is set to the 'default' then be able to reset said property back to the 'default'.

Defaults are strange with scoped properties because scoped properties are additive. You can set `some.setting` 10 times with similar scopes creating a chain of properties that need to be evaluated against a scoped descriptor. Which one of those set is the default? The path through those scoped properties depends on ordering and specificity when matched against a scopeDescriptor.

Defaults here rely on some simplifications based on our use of scoped settings.

1. Every value set in the property store has a `source` property indicating where it came from. Each scoped setting set via the user config file or `Config::set`, has this `source` property set to `user-config`. Scoped defaults can be any scoped property who's `source` property is not `user-config`. So anything set by a package's `scoped-properties.cson` is a default, and anything the user sets is an override.

2. The settings view needs to check and reset the default values with the same scope selector used to initially set the properties. Currently these selectors are language scopes: `'.source.js'`, etc. eg. The way it's written in this PR, we cannot reset the default for the scope descriptor `['.source.js', '.meta.function.name']`, but we can for `['.source.js']` because `'.source.js'` is the way it went in.

For reason number 2, all the methods; `isDefault`, `getDefault`, `restoreDefault`, `getSettings`; take a `scopeSelector`, not a `scopeDescriptor`.

Depends on https://github.com/atom/scoped-property-store/pull/5