       'autohide-tree-view:hide': =>
         @hide true
       'autohide-tree-view:toggle-visible': =>
-        if @enabled
-          @disableHoverEvents()
-          @toggle()
-        else
-          atom.commands.dispatch atom.views.getView(atom.workspace), 'tree-view:toggle'
+        @toggle()
       'autohide-tree-view:enable': =>
         @enable()
       'autohide-tree-view:disable': =>


  enable: =>
    @enabled = true
    @treeViewResizerEl.classList.add 'autohide'
    @hide(true)
    @update()

  disable: =>
    @enabled = false
    @treeViewResizerEl.classList.remove 'autohide', 'autohide-hover'
    @treeViewResizerEl.style.width = "#{@treeViewEl.clientWidth}px"
    @treeViewResizerEl.parentNode?.style?.width = ''

  update: =>
    if @conf.pushEditor
      @treeViewResizerEl.style.position = 'relative'
      @treeViewResizerEl.parentNode?.style?.width = ''
    else
      @treeViewResizerEl.style.position = 'absolute'
      @treeViewResizerEl.parentNode?.style?.width = "#{@conf.hiddenWidth}px"

  show: (noDelay = false) ->
    if @conf.hiddenWidth < @treeViewResizerEl.clientWidth < @treeViewEl.clientWidth
      noDelay = true
    setTimeout =>
      @visible = true
      @animate @treeViewEl.clientWidth
    , Number(!noDelay) * @conf.showDelay
    if @conf.focusTreeViewOnOpen
      @treeView.focus()

  hide: (noDelay = false) ->
    if @conf.hiddenWidth < @treeViewResizerEl.clientWidth < @treeViewEl.clientWidth
      noDelay = true
    setTimeout =>
      @visible = false
      @animate @conf.hiddenWidth
    , Number(!noDelay) * @conf.hideDelay
    @enableHoverEvents()
    if @conf.unfocusTreeViewOnClose
      @treeView.unfocus()

  toggle: =>
    if @visible
      @hide()
    else
      @show()

  openEntry: (e) =>
    if @treeView.selectedEntry().classList.contains 'directory'

    @disposables = new SubAtom()
    atom.packages.activatePackage('tree-view').then (treeViewPkg) =>
      @treeView = treeViewPkg.mainModule.createView()
      @treeViewEl = atom.views.getView @treeView
      @subscribeEventHandlers()
      @enable()
    .catch (error) ->
