     @css {left: left, top: top + @editor.lineHeight}
     $(document.body).append(this)
     @focus()
+
+  detach: ->
+    @editor.removeClass('autocomplete')
+    super
 
   previousMatch: ->
     previousIndex = @currentMatchIndex - 1


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

  buildWordList: () ->

  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()
