 
   destroy: ->
     @misspellingValid = false
-    @editor.destroyMarker(@marker)
     @correctionsView?.remove()
     @remove()


  initialize: (range, @editorView) ->
    @editor = @editorView.getEditor()
    range = @editor.screenRangeForBufferRange(Range.fromObject(range))
    @startPosition = range.start
    @endPosition = range.end
    @misspellingValid = true

    @marker = @editor.markScreenRange(range, invalidation: 'inside', replicate: false)
    @marker.on 'changed', ({newHeadScreenPosition, newTailScreenPosition, isValid}) =>
      @startPosition = newTailScreenPosition
      @endPosition = newHeadScreenPosition
      @updateDisplayPosition = isValid
      @misspellingValid = isValid
      @hide() unless isValid

    @subscribe @editorView, 'spell-check:display-updated', =>
      @updatePosition() if @updateDisplayPosition


    @updatePosition()

  createMarker: ->
    @marker = @editor.markScreenRange(@getScreenRange(), invalidation: 'inside', replicate: false)
    @marker.on 'changed', ({newHeadScreenPosition, newTailScreenPosition, isValid}) =>
      @startPosition = newTailScreenPosition
      @endPosition = newHeadScreenPosition
      @updateDisplayPosition = isValid
      @misspellingValid = isValid
      @hide() unless isValid

  getScreenRange: ->
    new Range(@startPosition, @endPosition)

  getCorrections: ->
    screenRange = @getScreenRange()
    misspelling = @editor.getTextInRange(@editor.bufferRangeForScreenRange(screenRange))
    SpellChecker = require 'spellchecker'
    corrections = SpellChecker.getCorrectionsForMisspelling(misspelling)

  beforeRemove: ->
