Only add view when grammars-loaded event fires

Previously the views would be added immediately
if more than one grammar was already registered.

This was unneeded since the event will always fire
after the package is activated.
This commit is contained in:
Kevin Sawicki
2013-03-21 17:22:37 -07:00
parent f8ffe1c408
commit a362a14f75
2 changed files with 5 additions and 4 deletions

View File

@@ -9,10 +9,10 @@ module.exports =
]
activate: ->
if syntax.grammars.length > 1
@subscribeToEditors()
else
syntax.on 'grammars-loaded', => @subscribeToEditors()
syntax.on 'grammars-loaded.spell-check', => @subscribeToEditors()
deactivate: ->
syntax.off '.spell-check'
subscribeToEditors: ->
rootView.eachEditor (editor) ->

View File

@@ -8,6 +8,7 @@ describe "Spell check", ->
rootView.open('sample.js')
config.set('spell-check.grammars', [])
window.loadPackage('spell-check', activateImmediately: true)
syntax.trigger 'grammars-loaded'
rootView.attachToDom()
editor = rootView.getActiveView()