 
   select: ->
     @editor.getSelection().clearSelection()
-    @remove()
+    @detach()
     @editor.focus()
 
   buildWordList: () ->

    @css {left: left, top: top + @editor.lineHeight}
    $(document.body).append(this)
    @focus()

  previousMatch: ->
    previousIndex = @currentMatchIndex - 1

  cancel: ->
    @editor.getSelection().insertText @originalSelectedText
    @editor.setSelectionBufferRange(@originalSelectionBufferRange)
    @detach()

  toggle: ->
    if @parent()[0] then @detach() else @attach()

  attach: ->
    @editor.addClass('autocomplete')
    @originalSelectedText = @editor.getSelectedText()
    @originalSelectionBufferRange = @editor.getSelection().getBufferRange()
    @buildMatchList()
