   new Promise (resolve) ->
     process.nextTick ->
       resolve()
+
+getConfig = (key) -> atom.config.get "autohide-tree-view.#{key}"
+
+setConfig = (key, value) -> atom.config.set "autohide-tree-view.#{key}", value
 
 class AutohideTreeView
   config:

      @treeView.focus() if finished

  # hide the tree view
  hide: (delay = @conf.hideDelay) ->
    @visible = false
    # enable hover events again
    @enableHoverEvents()
    # focus the element that was focused before the tree view
    # was opened
    @recoverFocus()
    @animate @conf.hiddenWidth, delay
    .then (finished) =>
      # hide the tree view content
      @treeView.scroller[0].style.display = 'none' if finished

      @handleEvents()
      # start with pushEditor = true, we'll change it back later
      # activating the package looks much better this way
      setConfig 'pushEditor', true
      @update()
    .then =>
      # reset the pushEditor setting to the user value
      setConfig 'pushEditor', pushEditor
      @update()
    .catch error

  deactivate: ->
    # deactivating looks better with pushEditor = true
    pushEditor = getConfig 'pushEditor'
    setConfig 'pushEditor', true
    # the stylesheet will be removed before the animation is finished
    # so set minWidth on the element
    @treeViewEl.style.minWidth = '1px'
    # apply new pushEditor value, then show the tree view
    @update().then =>
      # reset the pushEditor setting to the user value
      setConfig 'pushEditor', pushEditor
      # show the tree view
      @show 0
    .then =>
      # finally dispose of everything
      @disposables.dispose()
      [@disposables, @visible] = []
    .catch error

  registerTreeView: (treeViewPkg) ->
