From a0766d9b69d3794154591a3cebf027c813729e78 Mon Sep 17 00:00:00 2001 From: Katrina Uychaco Date: Fri, 25 Aug 2017 20:29:07 -0700 Subject: [PATCH] Ensure set/unset operations take place after user's config is loaded --- src/config.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/config.coffee b/src/config.coffee index 389350ef9..6c47caf88 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -399,6 +399,8 @@ class Config # Created during initialization, available as `atom.config` constructor: ({@notificationManager, @enablePersistence}={}) -> + @settingsLoaded = false + @pendingOperations = [] @clear() initialize: ({@configDirPath, @resourcePath, projectHomeSchema}) -> @@ -646,6 +648,10 @@ 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: -> + unless @settingsLoaded + @pendingOperations.push(() => @set.apply(@, arguments)) + return + [keyPath, value, options] = arguments scopeSelector = options?.scopeSelector source = options?.source @@ -677,6 +683,10 @@ class Config # * `scopeSelector` (optional) {String}. See {::set} # * `source` (optional) {String}. See {::set} unset: (keyPath, options) -> + unless @settingsLoaded + @pendingOperations.push(() => @unset.apply(@, arguments)) + return + {scopeSelector, source} = options ? {} source ?= @getUserConfigPath() @@ -944,7 +954,12 @@ class Config @transact => @settings = {} + @settingsLoaded = true @set(key, value, save: false) for key, value of newSettings + if @pendingOperations.length + op() for op in @pendingOperations + @debouncedSave() + @pendingOperations = [] return getRawValue: (keyPath, options) ->