<commit_before>fs = require 'fs-plus'

changeStrategies = {
  moved_from: ({virtualFileSystem, projectNode, path}) ->
    node = projectNode.remove(path)

    # ignore weird vim write events
    return node if node.siblings().find (sibling) ->
      sibling.name is "#{node.name}.swp"

    fs.remove node.localPath(), (err) ->
      if err?
        console.error 'Unable to remove local file:', err

    node

  delete: (data) ->
    changeStrategies.moved_from(data)

  moved_to: ({virtualFileSystem, projectNode, virtualFile}) ->
    node = projectNode.add(virtualFile)
    virtualFileSystem.sync(node.path)
    node

  create: (data) ->
    changeStrategies.moved_to(data)

  close_write: ({virtualFileSystem, projectNode, virtualFile, atomHelper}) ->
    node = projectNode.update(virtualFile)

    if not atomHelper.saveEditorForPath(node.localPath())
      node.determineSync().then (shouldSync) ->
        if shouldSync
          virtualFileSystem.fetch(node.path)

    node
}
<commit_msg>Cleanup create and delete changes<commit_after>fs = require 'fs-plus'

changeStrategies = {
  delete: ({virtualFileSystem, projectNode, path}) ->
    node = projectNode.remove(path)

    # ignore weird vim write events
    return node if node.siblings().find (sibling) ->
      sibling.name is "#{node.name}.swp"

    fs.remove node.localPath(), (err) ->
      if err?
        console.error 'Unable to remove local file:', err

    node

  moved_from: (data) ->
    changeStrategies.delete(data)

  create: ({virtualFileSystem, projectNode, virtualFile}) ->
    node = projectNode.add(virtualFile)

    node.findPathsToSync().then (paths) ->
      virtualFileSystem.fetch(paths)

    node

  moved_to: (data) ->
    changeStrategies.create(data)

  close_write: ({virtualFileSystem, projectNode, virtualFile, atomHelper}) ->
    node = projectNode.update(virtualFile)

    if not atomHelper.saveEditorForPath(node.localPath())
      node.determineSync().then (shouldSync) ->
        if shouldSync
          virtualFileSystem.fetch(node.path)

    node
}

{'fraction_non_alphanumeric': 0.12048780487804878, 'fraction_numerical': 0.0, 'mean_word_length': 3.327004219409283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1212064', 'n_tokens_mistral': 644, 'n_tokens_neox': 631, 'n_words': 138}