 'use strict'
 path = require 'path'
 SubAtom = require 'sub-atom'
-
-# debug = do ->
-#   log = ''
-#   length = 0
-#   timeout = null
-#
-#   (message) ->
-#     clearTimeout timeout
-#     timeout = setTimeout ->
-#       fs.writeFileSync "#{__dirname}/../log", log
-#     , 500
 
 class AutohideTreeView
   treeView = null

  show: (noDelay, disableHoverEvents) ->
    return unless @enabled
    @applyHiddenWidth()
    width = treeViewEl.querySelector('.tree-view').clientWidth
    if width > treeViewEl.clientWidth > @getHiddenWidth()
      noDelay = true

    @initialized = true

  enable: (treeViewPkg) ->
    treeViewPkg ?= atom.packages.getActivePackage 'tree-view'
    return unless treeViewPkg?
    @enabled = true
    treeView = treeViewPkg.mainModule.createView()
    treeViewEl = atom.views.getView treeView
    treeViewEl.classList.add 'autohide', 'autohide-hover-events'
    @applyHiddenWidth()
    @applyAnimate()
    @hide true

  disable: ->
    @enabled = false
