Always unsubscribe when changing buffers

Previously subscribeToBuffer() returned early
in certain cases without first unsubscribing to
the current buffer.
This commit is contained in:
Kevin Sawicki
2013-03-01 10:54:52 -08:00
parent 7bfb07a25a
commit 58bd83a225

View File

@@ -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