     return true
 
   registerEvents: ->
-    @disposables.push atom.project.onDidChangePaths (paths) =>
-      @checkPaths(paths)
     @disposables.push atom.commands.add 'atom-text-editor', 'tern:references': (event) =>
       if !@reference
         Reference = require './atom-ternjs-reference'

    @registerHelperCommands()
    @provider.init(this)
    @initServers()

  init: ->
    @setActiveServerAndClient()
    @initialised = true
    @registerEvents()
    @registerCommands()

      @client = false

  checkPaths: (paths) ->
    for path in paths
      dir = atom.project.relativizePath(path)[0]
      @startServer(dir)

  destroyServer: (paths) ->
    return unless @servers.length
    serverIdx = undefined
    for i in [0..@servers.length - 1]
      if paths.indexOf(@servers[i].rootPath) is -1
        serverIdx = i
    return if serverIdx is undefined
    server = @servers[serverIdx]
    client = @getClientForProject(server.rootPath)
    client.unregisterEvents()
    client = null
    server.stop()
    server = null
    @servers.splice(serverIdx, 1)

  getServerForProject: (rootPath) ->
    for server in @servers
