<commit_before>{$, $$, View} = require 'atom'

Directory = require './directory'
FileView = require './file-view'
File = require './file'

module.exports =
class DirectoryView extends View
  @content: ->
    @li class: 'directory entry list-nested-item', =>
      @div outlet: 'header', class: 'header list-item', =>
        @span class: 'name icon', outlet: 'directoryName'
      @ol class: 'entries list-tree', outlet: 'entries'

  initialize: ({@directory, isExpanded, isRoot} = {}) ->
    if @directory.symlink
      iconClass = 'icon-file-symlink-directory'
    else
      iconClass = 'icon-file-directory'
      if isRoot?
        iconClass = 'icon-repo' if atom.project.getRepo()?.isProjectAtRoot()
      else
        iconClass = 'icon-file-submodule' if @directory.submodule
    @directoryName.addClass(iconClass)
    @directoryName.text(@directory.name)

    unless isRoot?
      @subscribe @directory.$status.onValue (status) =>
        @removeClass('status-ignored status-modified status-added')
        @addClass("status-#{status}") if status?

    @subscribe @directory, 'entry-added', (entry) =>
      view = @createViewForEntry(entry)
      insertionIndex = entry.indexInParentDirectory
      if insertionIndex < @entries.children().length
        @entries.children().eq(insertionIndex).before(view)
      else
        @entries.append(view)

    if isExpanded then @expand() else @collapse()

    @subscribe @directory, 'entry-removed entry-removed', =>
      @trigger 'tree-view:directory-modified'

  beforeRemove: ->
    @directory.destroy()

  getPath: ->
    @directory.path

  createViewForEntry: (entry) ->
    if entry instanceof Directory
      view = new DirectoryView(directory: entry)
    else
      view = new FileView(entry)
<commit_msg>Subscribe to entry-added as well<commit_after>{$, $$, View} = require 'atom'

Directory = require './directory'
FileView = require './file-view'
File = require './file'

module.exports =
class DirectoryView extends View
  @content: ->
    @li class: 'directory entry list-nested-item', =>
      @div outlet: 'header', class: 'header list-item', =>
        @span class: 'name icon', outlet: 'directoryName'
      @ol class: 'entries list-tree', outlet: 'entries'

  initialize: ({@directory, isExpanded, isRoot} = {}) ->
    if @directory.symlink
      iconClass = 'icon-file-symlink-directory'
    else
      iconClass = 'icon-file-directory'
      if isRoot?
        iconClass = 'icon-repo' if atom.project.getRepo()?.isProjectAtRoot()
      else
        iconClass = 'icon-file-submodule' if @directory.submodule
    @directoryName.addClass(iconClass)
    @directoryName.text(@directory.name)

    unless isRoot?
      @subscribe @directory.$status.onValue (status) =>
        @removeClass('status-ignored status-modified status-added')
        @addClass("status-#{status}") if status?

    @subscribe @directory, 'entry-added', (entry) =>
      view = @createViewForEntry(entry)
      insertionIndex = entry.indexInParentDirectory
      if insertionIndex < @entries.children().length
        @entries.children().eq(insertionIndex).before(view)
      else
        @entries.append(view)

    if isExpanded then @expand() else @collapse()

    @subscribe @directory, 'entry-added entry-removed', =>
      @trigger 'tree-view:directory-modified'

  beforeRemove: ->
    @directory.destroy()

  getPath: ->
    @directory.path

  createViewForEntry: (entry) ->
    if entry instanceof Directory
      view = new DirectoryView(directory: entry)
    else
      view = new FileView(entry)

{'fraction_non_alphanumeric': 0.13553113553113552, 'fraction_numerical': 0.0, 'mean_word_length': 3.266826923076923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '1520033', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1021, 'n_words': 246}