 
   deactivate: ->
     @subscriptions.dispose()
+    for key, disposables @editorSubscriptions
+      disposables.dispose()
+    @editorSubscriptions = null
     settings.dispose()
     @history?.destroy()
     @history = null

      Flasher.flash() if settings.get('flashOnLand')
      @history.dump direction

  handleChangePath: (editor) ->
    orgURI = editor.getURI()

    @subscriptions.add editor.onDidChangePath =>
      newURI = editor.getURI()
      @history.rename orgURI, newURI
      @lastEditor.rename orgURI, newURI

  config: settings.config
  history: null
  subscriptions: null
  editorSubscriptions: null
  lastEditor: null
  locked: false

  onWillJumpToHistory: (callback) ->
    @emitter.on 'will-jump-to-history', callback

  onDidJumpToHistory:  (callback) ->
    @emitter.on 'did-jump-to-history', callback

  activate: (state) ->
    @subscriptions = new CompositeDisposable
    @editorSubscriptions = {}
    @emitter       = new Emitter
    @history       = new History settings.get('max')

