From 58bd83a2259bb428fbb9da10536d26dffa3ce391 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 1 Mar 2013 10:54:52 -0800 Subject: [PATCH] Always unsubscribe when changing buffers Previously subscribeToBuffer() returned early in certain cases without first unsubscribing to the current buffer. --- .../spell-check/lib/spell-check-view.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/packages/spell-check/lib/spell-check-view.coffee b/src/packages/spell-check/lib/spell-check-view.coffee index 2117dc3ef..323d0e873 100644 --- a/src/packages/spell-check/lib/spell-check-view.coffee +++ b/src/packages/spell-check/lib/spell-check-view.coffee @@ -21,12 +21,15 @@ class SpellCheckView extends View subscribeToBuffer: -> @destroyViews() @task?.abort() - return unless @spellCheckCurrentGrammar() - @buffer?.off '.spell-check' - @buffer = @editor.getBuffer() - @buffer.on 'contents-modified.spell-check', => @updateMisspellings() - @updateMisspellings() + if @buffer? + @buffer.off '.spell-check' + @buffer = null + + if @spellCheckCurrentGrammar() + @buffer = @editor.getBuffer() + @buffer.on 'contents-modified.spell-check', => @updateMisspellings() + @updateMisspellings() spellCheckCurrentGrammar: -> grammar = @editor.getGrammar().scopeName