<commit_before>{View, $$} = require 'space-pen'
SelectList = require 'select-list'
_ = require 'underscore'
$ = require 'jquery'
fs = require 'fs'

module.exports =
class FuzzyFinder extends SelectList
  @activate: (rootView) ->
    requireStylesheet 'fuzzy-finder.css'
    @instance = new FuzzyFinder(rootView)
    rootView.command 'fuzzy-finder:toggle-file-finder', => @instance.toggleFileFinder()
    rootView.command 'fuzzy-finder:toggle-buffer-finder', => @instance.toggleBufferFinder()

  @viewClass: ->
    [super, 'fuzzy-finder'].join(' ')

  allowActiveEditorChange: null
  maxItems: 10
  projectPaths: null

  initialize: (@rootView) ->
    super
    $(window).on 'focus', => @projectPaths = null
    @observeConfig 'fuzzy-finder.ignoredNames', (ignoredNames) =>
      @projectPaths = null

  itemForElement: (path) ->
    $$ ->
      @li =>
        ext = fs.extension(path)
        if fs.isCompressedExtension(ext)
          typeClass = 'compressed-name'
        else if fs.isImageExtension(ext)
          typeClass = 'image-name'
        else if fs.isPdfExtension(ext)
          typeClass = 'pdf-name'
        else
          typeClass = 'text-name'
        @span fs.base(path), class: "file #{typeClass}"
        if folder = fs.directory(path)
          @span "- #{folder}/", class: 'directory'
<commit_msg>Use subscribe for window focus listener<commit_after>{View, $$} = require 'space-pen'
SelectList = require 'select-list'
_ = require 'underscore'
$ = require 'jquery'
fs = require 'fs'

module.exports =
class FuzzyFinder extends SelectList
  @activate: (rootView) ->
    requireStylesheet 'fuzzy-finder.css'
    @instance = new FuzzyFinder(rootView)
    rootView.command 'fuzzy-finder:toggle-file-finder', => @instance.toggleFileFinder()
    rootView.command 'fuzzy-finder:toggle-buffer-finder', => @instance.toggleBufferFinder()

  @viewClass: ->
    [super, 'fuzzy-finder'].join(' ')

  allowActiveEditorChange: null
  maxItems: 10
  projectPaths: null

  initialize: (@rootView) ->
    super
    @subscribe $(window), 'focus', => @projectPaths = null
    @observeConfig 'fuzzy-finder.ignoredNames', (ignoredNames) =>
      @projectPaths = null

  itemForElement: (path) ->
    $$ ->
      @li =>
        ext = fs.extension(path)
        if fs.isCompressedExtension(ext)
          typeClass = 'compressed-name'
        else if fs.isImageExtension(ext)
          typeClass = 'image-name'
        else if fs.isPdfExtension(ext)
          typeClass = 'pdf-name'
        else
          typeClass = 'text-name'
        @span fs.base(path), class: "file #{typeClass}"
        if folder = fs.directory(path)
          @span "- #{folder}/", class: 'directory'

{'fraction_non_alphanumeric': 0.13879536101758325, 'fraction_numerical': 0.0014964459408903852, 'mean_word_length': 3.0515151515151517, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2761155', 'n_tokens_mistral': 844, 'n_tokens_neox': 824, 'n_words': 178}