From a362a14f75bc2eddb33ab73b311d6ae261268b8a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 21 Mar 2013 17:22:37 -0700 Subject: [PATCH] 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. --- src/packages/spell-check/lib/spell-check.coffee | 8 ++++---- src/packages/spell-check/spec/spell-check-spec.coffee | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/packages/spell-check/lib/spell-check.coffee b/src/packages/spell-check/lib/spell-check.coffee index 2465b22df..9256e6c3c 100644 --- a/src/packages/spell-check/lib/spell-check.coffee +++ b/src/packages/spell-check/lib/spell-check.coffee @@ -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) -> diff --git a/src/packages/spell-check/spec/spell-check-spec.coffee b/src/packages/spell-check/spec/spell-check-spec.coffee index 0756dbdeb..6ccf41df5 100644 --- a/src/packages/spell-check/spec/spell-check-spec.coffee +++ b/src/packages/spell-check/spec/spell-check-spec.coffee @@ -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()