<commit_before>{Disposable} = require 'atom'

class FileInfoView extends HTMLElement
  initialize: ->
    @classList.add('file-info', 'inline-block')

    @currentPath = document.createElement('span')
    @currentPath.classList.add('current-path')
    @appendChild(@currentPath)

    @bufferModified = document.createElement('span')
    @bufferModified.classList.add('buffer-modified')
    @appendChild(@bufferModified)

    clickHandler = ->
      atom.clipboard.write('helloworld')

    @addEventListener('click', clickHandler)
    @clickSubscription = new Disposable => @removeEventListener('click', clickHandler)

    @activeItemSubscription = atom.workspace.onDidChangeActivePaneItem =>
      @subscribeToActiveItem()
    @subscribeToActiveItem()

  subscribeToActiveItem: ->
    @modifiedSubscription?.dispose()
    @titleSubscription?.dispose()

    if activeItem = @getActiveItem()
      @updateCallback ?= => @update()

      if typeof activeItem.onDidChangeTitle is 'function'
        @titleSubscription = activeItem.onDidChangeTitle(@updateCallback)
      else if typeof activeItem.on is 'function'
        #TODO Remove once title-changed event support is removed
        activeItem.on('title-changed', @updateCallback)
        @titleSubscription = dispose: =>
          activeItem.off?('title-changed', @updateCallback)

      @modifiedSubscription = activeItem.onDidChangeModified?(@updateCallback)

    @update()

  destroy: ->
    @activeItemSubscription.dispose()
    @titleSubscription?.dispose()
    @modifiedSubscription?.dispose()
    @clickSubscription?.dispose()

  getActiveItem: ->
    atom.workspace.getActivePaneItem()<commit_msg>add half-assed tooltip<commit_after>{Disposable} = require 'atom'

class FileInfoView extends HTMLElement
  initialize: ->
    @classList.add('file-info', 'inline-block')

    @currentPath = document.createElement('span')
    @currentPath.classList.add('current-path')
    @appendChild(@currentPath)

    @bufferModified = document.createElement('span')
    @bufferModified.classList.add('buffer-modified')
    @appendChild(@bufferModified)

    @absolutePath = @getActiveItem()?.getPath?()


    clickHandler = ->
      @tempTip = atom.tooltips.add(this,
        title: 'Copied: '+atom.clipboard.read(),
        trigger: 'click',
        delay:
          show: 0
          hide: 1000
      )
      killTip = => @tempTip.dispose()
      atom.clipboard.write(@absolutePath)
      setTimeout(killTip, 1000)

    @addEventListener('click', clickHandler)
    @clickSubscription = new Disposable => @removeEventListener('click', clickHandler)

    @activeItemSubscription = atom.workspace.onDidChangeActivePaneItem =>
      @subscribeToActiveItem()
    @subscribeToActiveItem()

  subscribeToActiveItem: ->
    @modifiedSubscription?.dispose()
    @titleSubscription?.dispose()

    if activeItem = @getActiveItem()
      @updateCallback ?= => @update()

      if typeof activeItem.onDidChangeTitle is 'function'
        @titleSubscription = activeItem.onDidChangeTitle(@updateCallback)
      else if typeof activeItem.on is 'function'
        #TODO Remove once title-changed event support is removed
        activeItem.on('title-changed', @updateCallback)
        @titleSubscription = dispose: =>
          activeItem.off?('title-changed', @updateCallback)

      @modifiedSubscription = activeItem.onDidChangeModified?(@updateCallback)

    @update()

  destroy: ->
    @activeItemSubscription.dispose()
    @titleSubscription?.dispose()
    @modifiedSubscription?.dispose()
    @clickSubscription?.dispose()
    @tempTip?.dispose()

  getActiveItem: ->
    atom.workspace.getActivePaneItem()
{'fraction_non_alphanumeric': 0.1215363511659808, 'fraction_numerical': 0.0024691358024691358, 'mean_word_length': 3.9071332436069985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '7525408', 'n_tokens_mistral': 1011, 'n_tokens_neox': 995, 'n_words': 172}