mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Transact on both async and sync package activation
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user