Fix issue with looking up objects in atom.config
…
#897
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…when a project-specific config is present.
Identify the Bug
The symptom: indentation queries that used
test.config
predicates weren't reacting to changes in config. If a certain indentation behavior is dependent on a setting, and I toggle the setting, I shouldn't have to relaunch the window to get the behavior to change. But that's not what I was experiencing!Description of the Change
We cache config lookups in
ScopeResolver
for performance. To know when to invalidate that cache, instead of creating a new listener every time an individual predicate consumes a specific setting, we listen once on the entire config object and clear our cache whenever it changes for any reason.Ordinarily, a call to
atom.config.get()
without an argument:core
,editor
, and all my package names)But because I have an empty
.atom
folder at the root of my project (because at one point I was applying project-specific settings via atomic-management), a call toatom.config.get()
with no argument:core
,editor
, and all my package names)The logic that prefers a project-specific value when present… well, it works great with primitive values, but not with objects.
The effect here is that, when I called
atom.config.get()
with no argument, I got an object filled with all of the default values. Every time, no matter how weird my actual config settings got. This bug propagated toonDidChange
becauseonDidChange
handlers that listen for object values will only get called if an object is substantively different in value, not just reference, and the value never seemed to change, even when I was changing options.The fix is pretty easy:
core
,editor
, and all my package names)Alternate Designs
I did not think of any. This is a pattern that is used later in the same function, so it was the obvious solution.
Possible Drawbacks
I can't think of any. Blending these objects will be slightly costlier than before, but there's no way around it if you're offering people this abstraction.
Verification Process
Run the specs.
Release Notes