       "autocomplete-plus:select-next": @selectNext,
       "autocomplete-plus:select-previous": @selectPrevious,
       "autocomplete-plus:cancel": @cancel
+
+  updateCurrentEditor: (currentPaneItem) =>
+    @cancel() unless currentPaneItem == @editor
 
   confirmSelection: =>
     @emitter.emit 'do-confirm-selection'

    @handleEvents()
    @setCurrentBuffer @editor.getBuffer()

    @compositeDisposable.add atom.commands.add 'atom-text-editor',
      "autocomplete-plus:activate": @runAutocompletion


    @editor.insertText(match.word)
    @editor.setSelectedBufferRanges(newSelectedBufferRanges)

  # Private: Sets the current buffer, starts listening to change events and delegates
  # them to #onChanged()
  #
