Transact on both async and sync package activation

This commit is contained in:
Antonio Scandurra
2015-11-10 11:05:31 +01:00
parent 46665c1f8b
commit e437234c58
2 changed files with 16 additions and 8 deletions

View File

@@ -671,12 +671,18 @@ class Config
#
# * `callback` {Function} to execute while suppressing calls to handlers.
transact: (callback) ->
@transactDepth++
@startTransaction()
try
callback()
finally
@transactDepth--
@emitChangeEvent()
@endTransaction()
startTransaction: ->
@transactDepth++
endTransaction: ->
@transactDepth--
@emitChangeEvent()
###
Section: Internal methods used by core

View File

@@ -416,11 +416,13 @@ class PackageManager
activatePackages: (packages) ->
promises = []
@config.transact =>
for pack in packages
promise = @activatePackage(pack.name)
promises.push(promise) unless pack.hasActivationCommands()
return
@config.startTransaction()
for pack in packages
promise = @activatePackage(pack.name)
promises.push(promise) unless pack.hasActivationCommands()
Promise.all(promises)
.then(=> @config.endTransaction())
.catch(=> @config.endTransaction())
@observeDisabledPackages()
@observePackagesWithKeymapsDisabled()
promises