-fs = require 'fs'
+{watchPath} = require('atom')
 {join} = require 'path'
 {Directory, CompositeDisposable} = require 'atom'
 {repositoryForPath} = require './helpers'

      @addIndexWatch()

  addIndexWatch: ->
    @indexWatch?.close()
    @indexWatch = fs.watch join(@repository.getPath(), 'index'), =>
      # atom/git-utils Repository does not always detect index changes
      # ... let others know (e.g. tree-view)
      @repository?.refreshStatus()
      @scheduleUpdate()
      @addIndexWatch()

  cancelUpdate: ->
    clearTimeout(@timeoutId)

    @subscriptions = new CompositeDisposable()
    @decorations = {}
    @markers = []
    @timeoutId = @repository = @editor = null

  dispose: =>
    @cancelUpdate()
    @removeDecorations()
    @subscriptions?.dispose()
    @reset()

