     treeView.unfocus()
     @enableHoverEvents()
 
+  openEntry: (event) ->
+    if treeView.selectedEntry().classList.contains 'directory'
+      @show true
+    else if event.type isnt 'click'
+      @hide true
+
+  # apply the hiddenWidth setting
   applyHiddenWidth: (width = atom.config.get 'autohide-tree-view.hiddenWidth') ->
     treeViewEl.style.setProperty 'width', "#{width}px"
     treeViewEl.parentNode.style.setProperty 'width', "#{width}px", 'important'
 
+  # enable the hover events on the tree view
   enableHoverEvents: ->
     treeViewEl.classList.add 'autohide-hover-events'
 
+  # disable the hover events on the tree view
   disableHoverEvents: ->
     treeViewEl.classList.remove 'autohide-hover-events'
 

    @subs.add atom.packages.onDidDeactivatePackage (pkg) ->
      treeView = treeViewEl = null if pkg.path.match /\/tree-view\/?/i

    # following events should be fired AFTER tree-view is done handling them
    @subs.add treeViewEl, 'click', '.entry', (event) =>
      # console.log event.target, event.currentTarget
      if event.currentTarget.classList.contains 'directory'
        @show true
      else
        @hide true
    @subs.add treeViewEl,
      'tree-view:expand-directory': => @show true
      'tree-view:recursive-expand-directory': => @show true
      'tree-view:collapse-directory': => @show true
      'tree-view:recursive-collapse-directory': => @show true
      'tree-view:open-selected-entry': => @hide true
    @subs.add atom.config.observe 'tree-view:showOnRightSide', =>
      @applyHiddenWidth()

  toggleEnabled: ->
    if @enabled
      @disable()
    else
      @enable()

  enable: ->
    treeViewEl.classList.add 'autohide'
    @applyHiddenWidth()

    treeViewEl.style.width = treeViewEl.querySelector('.tree-view').clientWidth
    @enabled = false

  # show/hide the tree view
  toggleVisible: ->
    if treeViewEl.classList.contains 'unfolded'
      @hide true
    else
      @show true, true

  # show the tree view
  show: (noDelay, disableHoverEvents) ->
    width = treeViewEl.querySelector('.tree-view').clientWidth
    noDelay = true if width > treeViewEl.clientWidth > atom.config.get 'autohide-tree-view.hiddenWidth'
