       @disposables.add atom.styles.onDidRemoveStyleElement(onStylesheetsChanged)
       @disposables.add atom.styles.onDidUpdateStyleElement(onStylesheetsChanged)
 
-    @updateRoot(state.directoryExpansionStates)
-    @selectEntry(root) for root in @roots
+    @updateRoots(state.directoryExpansionStates)
+    @selectEntry(@roots[0])
 
     @selectEntryForPath(state.selectedPath) if state.selectedPath
     @focusAfterAttach = state.hasFocus

    @disposables.add atom.workspace.onDidChangeActivePaneItem =>
      @selectActiveFile()
    @disposables.add atom.project.onDidChangePaths =>
      @updateRoot()
    @disposables.add atom.config.onDidChange 'tree-view.hideVcsIgnoredFiles', =>
      @updateRoot()
    @disposables.add atom.config.onDidChange 'tree-view.hideIgnoredNames', =>
      @updateRoot()
    @disposables.add atom.config.onDidChange 'core.ignoredNames', =>
      @updateRoot() if atom.config.get('tree-view.hideIgnoredNames')
    @disposables.add atom.config.onDidChange 'tree-view.showOnRightSide', ({newValue}) =>
      @onSideToggled(newValue)
    @disposables.add atom.config.onDidChange 'tree-view.sortFoldersBeforeFiles', =>
      @updateRoot()

  toggle: ->
    if @isVisible()

      catch error
        console.warn "Error parsing ignore pattern (#{ignoredName}): #{error.message}"

  updateRoots: (expandedEntries={}) ->
    for root in @roots
      root.directory.destroy()
      root.remove()
