     @disposables.add atom.config.onDidChange 'tree-view.hideVcsIgnoredFiles', => @update()
     @disposables.add atom.config.onDidChange 'core.ignoredNames', => @update()
 
-    # add listeners for mouse events
+    # add listeners for mouse events and update them each time config.showOn gets updated
     mouseEventDisposables = null
     @disposables.add atom.config.observe 'autohide-tree-view.showOn', (value) =>
+      # dispose of previously set listeners
       mouseEventDisposables?.dispose()
       @disposables.add mouseEventDisposables = new SubAtom()
       if value.match 'hover'
+        # show the tree view when it is hovered
         mouseEventDisposables.add 'atom-workspace', 'mouseenter', '.tree-view-resizer.autohide-hover', => @show()
         mouseEventDisposables.add 'atom-workspace', 'mouseleave', '.tree-view-resizer.autohide-hover', => @hide()
         # disable the tree view from showing/hiding during a selection
         mouseEventDisposables.add 'atom-text-editor', 'mousedown', => @disableHoverEvents()
         mouseEventDisposables.add 'atom-text-editor', 'mouseup', => @enableHoverEvents()
       if value.match 'click'
+        # toggle the tree view when it is clicked
         mouseEventDisposables.add 'atom-workspace', 'click', '.tree-view-resizer', (event) => @toggle value is 'click'
+        # hide the tree view when another element is focused
         mouseEventDisposables.add '.tree-view', 'blur', =>
+          # clear the focused element so the user clicked element will be focused
           @clearFocusedElement()
           @hide 0
 

      @disposables.add atom.commands.add 'atom-workspace',
        "tree-view:#{command}", => @clearFocusedElement()

  update: ->
    promiseNextTick().then =>
      if @conf.pushEditor

    # 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 =>
      # show the tree view
      @show 0
    .then =>
      # finally dispose of everything
      @disposables.dispose()
      [@disposables, @conf, @visible] = []
    .catch error

  registerTreeView: (treeViewPkg) ->
    # keep references to the tree view element
    @treeView = treeViewPkg.mainModule.createView()
    @treeViewEl = @treeView.element
    @treeViewEl.classList.add 'autohide'

    # register a disposable that disposes of the references
    # and resets the styles
    @disposables.add new Disposable =>
      @treeViewEl.classList.remove 'autohide', 'autohide-hover'
      @treeViewEl.style.position = ''
