mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Terminate worker when all packages have been loaded
This commit is contained in:
parent
75da205b0a
commit
ee5d70b65d
@ -56,3 +56,22 @@ describe "the `atom` global", ->
|
||||
expect(stylesheetElementForId(stylesheetPath).length).toBe 0
|
||||
atom.loadPackage("package-with-module")
|
||||
expect(stylesheetElementForId(stylesheetPath).length).toBe 1
|
||||
|
||||
describe ".loadPackages()", ->
|
||||
beforeEach ->
|
||||
window.rootView = new RootView
|
||||
|
||||
it "terminates the worker when all packages have been loaded", ->
|
||||
spyOn(Worker.prototype, 'terminate').andCallThrough()
|
||||
eventHandler = jasmine.createSpy('eventHandler')
|
||||
rootView.on 'grammars-loaded', eventHandler
|
||||
disabledPackages = config.get("core.disabledPackages")
|
||||
disabledPackages.push('textmate-package.tmbundle')
|
||||
config.set "core.disabledPackages", disabledPackages
|
||||
atom.loadPackages()
|
||||
|
||||
waitsFor "all packages to load", 5000, -> eventHandler.callCount > 0
|
||||
|
||||
runs ->
|
||||
expect(Worker.prototype.terminate).toHaveBeenCalled()
|
||||
expect(Worker.prototype.terminate.calls.length).toBe 1
|
||||
|
@ -11,11 +11,15 @@ class LoadTextMatePackagesTask extends Task
|
||||
|
||||
loadNextPackage: ->
|
||||
unless @packages.length
|
||||
@terminate()
|
||||
rootView.trigger 'grammars-loaded'
|
||||
return
|
||||
|
||||
@package = @packages.shift()
|
||||
@callWorkerMethod('loadPackage', @package.name)
|
||||
@loadPackage(@package.name)
|
||||
|
||||
loadPackage: (name) ->
|
||||
@callWorkerMethod('loadPackage', name)
|
||||
|
||||
packageLoaded: (grammars) ->
|
||||
@package.loadGrammars(grammars)
|
||||
|
Loading…
Reference in New Issue
Block a user