     @workspaceView = atom.views.getView(atom.workspace)
     @projectPath = atom.project.getPaths()[0]
     @handleEvents()
-    @recentTreeViewCommand = null
 
   expandTreeView: ->
     atom.commands.dispatch(@workspaceView, 'tree-view:reveal-active-file')
 
   handleEvents: ->
     atom.commands.onWillDispatch (event) =>
-      switch event.type
-        when 'tree-view:add-file', 'tree-view:add-folder'
-          @onTreeViewAdd(event)
-        when 'tree-view:move'
-          @onTreeViewMove(event)
+      @onTreeViewWillDispatch(event) if event.type.match(/^tree-view/)
 
     atom.commands.onDidDispatch (event) =>
       console.log event.type

      path: @formatPath(path)

  localMove: (source, target) ->
    console.log '>>> 0'
    action: 'local_move'
    project:
      path: @formatPath(@projectPath)
    file:

    @sendLocalEvent @localSave(editor.project, file, buffer)

  onCoreConfirm: (event) ->
    setTimeout =>
      @syncAdditions()
      @syncMoves()
      @syncDuplication()
    , 10

  onTreeViewRemove: (event) =>
    @syncRemovals()

  onTreeViewWillDispatch: (event) =>
    {type, target} = event
    @pathAtWillDispatch = target.dataset.path || target.firstChild.dataset.path
    @willDispatchCommand = type
    @entriesAtWillDispatch = fs.listTreeSync(@projectPath)

  purgeTreeViewEvent: =>
    @pathAtWillDispatch = null
    @willDispatchCommand = null
    @entriesAtWillDispatch = null

  syncRemovals: =>
    prevEntries = @entriesAtWillDispatch

    return unless @willDispatchCommand is 'tree-view:remove'
    @purgeTreeViewEvent()

    removedEntries = _.difference(prevEntries, fs.listTreeSync(@projectPath))
    return unless removedEntries.length

    _.each removedEntries, (entry) => @sendLocalEvent @localRemove(entry)

  syncAdditions: =>
    prevEntries = @entriesAtWillDispatch

    return unless @willDispatchCommand?.match(/tree-view:add/)
    @purgeTreeViewEvent()

    return unless prevEntries?

