 _ = require 'underscore'
+Subscriber = require 'subscriber'
 
 module.exports =
 class GitDiffView

    @gutter = @editor.gutter
    @diffs = {}

    @editor.on 'editor:path-changed', => @subscribeToBuffer()
    @editor.on 'editor:display-updated', => @renderDiffs()
    git.on 'statuses-changed', =>
      @diffs = {}
      @scheduleUpdate()
    git.on 'status-changed', (path) =>
      delete @diffs[path]
      @scheduleUpdate() if path is @editor.getPath()

    @subscribeToBuffer()

  subscribeToBuffer: ->
    if @buffer?

        for row in [newStart...newStart + newLines]
          linesHighlighted += @gutter.find(".line-number[lineNumber=#{row - 1}]").addClass('git-line-modified').length
    @gutter.hasGitLineDiffs = linesHighlighted > 0

_.extend GitDiffView.prototype, Subscriber
