   client: null
   documentationView: null
   currentProviderIdx: 0
+  activeTextEditor: null
 
   # autocomplete
   autocompletePlus = null

    @client.update(editor.getURI(), editor.getText())

  findDefinition: ->
    editor = atom.workspace.getActiveTextEditor()
    cursor = editor.getLastCursor()
    position = cursor.getBufferPosition()
    @client.definition(editor.getURI(),
      line: position.row
      ch: position.column
    editor.getText()).then (data) =>
      if data?.start
        # check if definition is in current active TextEditor
        if atom.workspace.getActiveTextEditor().getPath().indexOf(data.file) > -1
          buffer = editor.getBuffer()
          cursor.setBufferPosition(buffer.positionForCharacterIndex(data.start))
          return
        # else open the file and set cursor position to definition


  registerCommands: ->
    atom.commands.add 'atom-text-editor', 'tern:definition': (event) =>
        @findDefinition()
    atom.commands.add 'atom-text-editor', 'tern:startCompletion': (event) =>
      @providers[@currentProviderIdx].callPreBuildSuggestions(true)
    atom.commands.add 'atom-text-editor', 'tern:stop': (event) =>
