mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Fix leak of LanguageMode objects in tests
This commit is contained in:
@@ -90,6 +90,7 @@ module.exports = class PackageManager {
|
||||
this.packagesCache = packageJSON._atomPackages != null ? packageJSON._atomPackages : {}
|
||||
this.packageDependencies = packageJSON.packageDependencies != null ? packageJSON.packageDependencies : {}
|
||||
this.triggeredActivationHooks.clear()
|
||||
this.activatePromise = null
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -114,6 +115,14 @@ module.exports = class PackageManager {
|
||||
return this.emitter.on('did-activate-initial-packages', callback)
|
||||
}
|
||||
|
||||
getActivatePromise() {
|
||||
if (this.activatePromise) {
|
||||
return this.activatePromise
|
||||
} else {
|
||||
return Promise.resolve()
|
||||
}
|
||||
}
|
||||
|
||||
// Public: Invoke the given callback when a package is activated.
|
||||
//
|
||||
// * `callback` A {Function} to be invoked when a package is activated.
|
||||
@@ -659,10 +668,11 @@ module.exports = class PackageManager {
|
||||
const packages = this.getLoadedPackagesForTypes(types)
|
||||
promises = promises.concat(activator.activatePackages(packages))
|
||||
}
|
||||
return Promise.all(promises).then(() => {
|
||||
this.activatePromise = Promise.all(promises).then(() => {
|
||||
this.triggerDeferredActivationHooks()
|
||||
this.initialPackagesActivated = true
|
||||
this.emitter.emit('did-activate-initial-packages')
|
||||
this.activatePromise = null
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -38,19 +38,10 @@ const EDITOR_PARAMS_BY_SETTING_KEY = [
|
||||
module.exports =
|
||||
class TextEditorRegistry {
|
||||
constructor ({config, assert, packageManager}) {
|
||||
this.assert = assert
|
||||
this.config = config
|
||||
this.assert = assert
|
||||
this.packageManager = packageManager
|
||||
this.clear()
|
||||
|
||||
this.initialPackageActivationPromise = new Promise((resolve) => {
|
||||
// TODO: Remove this usage of a private property of PackageManager.
|
||||
// Should PackageManager just expose a promise-based API like this?
|
||||
if (packageManager.deferredActivationHooks) {
|
||||
packageManager.onDidActivateInitialPackages(resolve)
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
deserialize (state) {
|
||||
@@ -216,7 +207,7 @@ class TextEditorRegistry {
|
||||
}
|
||||
|
||||
async updateAndMonitorEditorSettings (editor, oldLanguageMode) {
|
||||
await this.initialPackageActivationPromise
|
||||
await this.packageManager.getActivatePromise()
|
||||
this.updateEditorSettingsForLanguageMode(editor, oldLanguageMode)
|
||||
this.subscribeToSettingsForEditorScope(editor)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user