 Mixin = require 'mixto'
+{TextEditor} = require 'atom'
 {CompositeDisposable} = require 'event-kit'
 {deprecate} = require 'grim'
 MinimapView = null

    # the `eacheditorView` method. It returns a subscription object so we'll
    # store it and it will be used in the `deactivate` method to removes
    # the callback.
    @eachEditorViewSubscription = atom.workspace.observeTextEditors (editor) =>
      editorView = atom.views.getView(editor)
      MinimapView ||= require '../minimap-view'

      editorId = editor.id
      pane = atom.workspace.paneForItem(editor)
      paneView = atom.views.getView(pane)

      return unless paneView?

      if (view = @minimapViews[editorId])?
        view.setEditorView editorView
        view.detachFromPaneView()
        view.attachToPaneView()
        return

      view = new MinimapView(editorView)

      @minimapViews[editorId] = view

      event = {view}
      @emit('minimap-view:created', event)
      @emitter.emit('did-create-minimap', event)

      view.updateMinimapRenderView()

      subscriptions = new CompositeDisposable
      subscriptions.add editor.onDidDestroy =>
        view = @minimapViews[editorId]

        event = {view}
        if view?
          @emit('minimap-view:will-be-destroyed', event)
          @emitter.emit('will-destroy-minimap', event)

          view.destroy()
          delete @minimapViews[editorId]

          @emit('minimap-view:destroyed', {view})
          @emitter.emit('did-destroy-minimap', event)

          if paneView.getActiveView()?.classList.contains('editor')
            paneView.classList.add('with-minimap')

  # Internal: Destroys all views currently in use.
  destroyViews: ->
    view.destroy() for id, view of @minimapViews
    @observePaneSubscription?.dispose()
    @minimapViews = {}

  # Internal: Registers to each pane view existing or to be created and creates
