 module.exports =
 class ConflictMarker
 
-  Subscriber.includeInto this
+  constructor: (@state, @editorView) ->
+    @subs = new CompositeDisposable
 
-  constructor: (@state, @editorView) ->
     @conflicts = Conflict.all(@state, @editorView.getModel())
     @adapter = EditorAdapter.adapt(@editorView)
 

        unresolved = (v for v in @coveringViews when not v.conflict().isResolved())
        v.reposition() for v in unresolved
        resolvedCount = @conflicts.length - Math.floor(unresolved.length / 3)
        atom.emit 'merge-conflicts:resolved',
          file: @editor().getPath(),
          total: @conflicts.length, resolved: resolvedCount,
          source: this

      @conflictsResolved()

  installEvents: ->
    @subs.add @editor().onDidStopChanging => @detectDirty()
    @subs.add @editor().onDidDestroy => @cleanup()

    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:accept-current', => @acceptCurrent()
    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:accept-ours', => @acceptOurs()
    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:accept-theirs', => @acceptTheirs()
    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:ours-then-theirs', => @acceptOursThenTheirs()
    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:theirs-then-ours', => @acceptTheirsThenOurs()
    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:next-unresolved', => @nextUnresolved()
    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:previous-unresolved', => @previousUnresolved()
    @subs.add atom.commands.add 'atom-text-editor', 'merge-conflicts:revert-current', => @revertCurrent()

    @subs.add atom.emitter.on 'merge-conflicts:resolved', ({total, resolved, file}) =>
      if file is @editor().getPath() and total is resolved
        @conflictsResolved()

  cleanup: ->
    @subs.dispose()
    v.remove() for v in @coveringViews
    $(@editorView).removeClass 'conflicted'

