Don't throw exceptions when using editor APIs after destroying the editor

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2017-01-03 14:00:50 -08:00
committed by Nathan Sobo
parent 79e68b462d
commit 6f13159549
5 changed files with 9 additions and 14 deletions

View File

@@ -26,7 +26,6 @@ class Cursor extends Model
destroy: ->
@marker.destroy()
@marker = null
###
Section: Event Subscription

View File

@@ -26,8 +26,6 @@ class Selection extends Model
destroy: ->
@marker.destroy()
@marker = null
@decoration = null
isLastSelection: ->
this is @editor.getLastSelection()

View File

@@ -409,24 +409,14 @@ class TextEditor extends Model
destroyed: ->
@emitter.emit 'did-destroy'
@emitter = null
@emitter.clear()
@disposables.dispose()
@displayLayer.destroy()
@displayLayer = null
@defaultMarkerLayer = null
@tokenizedBuffer.destroy()
@tokenizedBuffer = null
selection.destroy() for selection in @selections.slice()
@selections = null
@cursors = null
@selectionsMarkerLayer = null
@buffer.release()
@buffer = null
@decorationManager = null
@languageMode.destroy()
@languageMode = null
@gutterContainer.destroy()
@gutterContainer = null
@editorElement = null
@presenter = null

View File

@@ -41,6 +41,7 @@ class TokenizedBuffer extends Model
destroyed: ->
@disposables.dispose()
@tokenizedLines.length = 0
buildIterator: ->
new TokenizedBufferIterator(this)
@@ -94,6 +95,7 @@ class TokenizedBuffer extends Model
false
retokenizeLines: ->
return unless @alive
@fullyTokenized = false
@tokenizedLines = new Array(@buffer.getLineCount())
@invalidRows = []