From 468f4a47a92292167cf4f5982af691095650c3de Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Wed, 6 Sep 2017 15:28:58 -0700 Subject: [PATCH] Fix another two tests --- spec/package-manager-spec.coffee | 3 ++- src/theme-manager.coffee | 36 +++++++++++++++----------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/spec/package-manager-spec.coffee b/spec/package-manager-spec.coffee index 294a2bfac..d0051a452 100644 --- a/spec/package-manager-spec.coffee +++ b/spec/package-manager-spec.coffee @@ -1375,7 +1375,8 @@ describe "PackageManager", -> atom.themes.activateThemes() afterEach -> - atom.themes.deactivateThemes() + waitsForPromise -> + atom.themes.deactivateThemes() it "enables and disables a theme", -> packageName = 'theme-with-package-file' diff --git a/src/theme-manager.coffee b/src/theme-manager.coffee index b6e36ba5b..742b86ddd 100644 --- a/src/theme-manager.coffee +++ b/src/theme-manager.coffee @@ -262,27 +262,25 @@ class ThemeManager new Promise (resolve) => # @config.observe runs the callback once, then on subsequent changes. @config.observe 'core.themes', => - @deactivateThemes() + @deactivateThemes().then => + @warnForNonExistentThemes() + @refreshLessCache() # Update cache for packages in core.themes config - @warnForNonExistentThemes() + promises = [] + for themeName in @getEnabledThemeNames() + if @packageManager.resolvePackagePath(themeName) + promises.push(@packageManager.activatePackage(themeName)) + else + console.warn("Failed to activate theme '#{themeName}' because it isn't installed.") - @refreshLessCache() # Update cache for packages in core.themes config - - promises = [] - for themeName in @getEnabledThemeNames() - if @packageManager.resolvePackagePath(themeName) - promises.push(@packageManager.activatePackage(themeName)) - else - console.warn("Failed to activate theme '#{themeName}' because it isn't installed.") - - Promise.all(promises).then => - @addActiveThemeClasses() - @refreshLessCache() # Update cache again now that @getActiveThemes() is populated - @loadUserStylesheet() - @reloadBaseStylesheets() - @initialLoadComplete = true - @emitter.emit 'did-change-active-themes' - resolve() + Promise.all(promises).then => + @addActiveThemeClasses() + @refreshLessCache() # Update cache again now that @getActiveThemes() is populated + @loadUserStylesheet() + @reloadBaseStylesheets() + @initialLoadComplete = true + @emitter.emit 'did-change-active-themes' + resolve() deactivateThemes: -> @removeActiveThemeClasses()