<commit_before>{$} = require 'atom-space-pen-views'
{CompositeDisposable, Disposable, TextBuffer} = require 'atom'

SelectNext = require './select-next'
{History, HistoryCycler} = require './history'
FindOptions = require './find-options'
BufferSearch = require './buffer-search'
FileIcons = require './file-icons'
FindView = require './find-view'
ProjectFindView = require './project-find-view'
ResultsModel = require './project/results-model'
ResultsPaneView = require './project/results-pane'

# Convert old config setting for backward compatibility.
if atom.config.get('find-and-replace.openProjectFindResultsInRightPane')
  atom.config.set('find-and-replace.projectSearchResultsPaneSplitDirection', 'right')
  atom.config.unset('find-and-replace.openProjectFindResultsInRightPane')

module.exports =
  activate: ({findOptions, findHistory, replaceHistory, pathsHistory}={}) ->
    atom.workspace.addOpener (filePath) ->
      new ResultsPaneView() if filePath is ResultsPaneView.URI

    @subscriptions = new CompositeDisposable
    @findHistory = new History(findHistory)
    @replaceHistory = new History(replaceHistory)
    @pathsHistory = new History(pathsHistory)

    @findOptions = new FindOptions(findOptions)
    @findModel = new BufferSearch(@findOptions)
    @resultsModel = new ResultsModel(@findOptions)

    @subscriptions.add atom.workspace.observeActivePaneItem (paneItem) =>
      if paneItem?.getBuffer?()
        @findModel.setEditor(paneItem)
      else
        @findModel.setEditor(null)

    @subscriptions.add atom.commands.add '.find-and-replace, .project-find', 'window:focus-next-pane', ->
      atom.views.getView(atom.workspace).focus()

    @subscriptions.add atom.commands.add 'atom-workspace', 'project-find:show', =>
      @createViews()
      showPanel @projectFindPanel, @findPanel, => @projectFindView.focusFindElement()
<commit_msg>Avoid config calls at package load time<commit_after>{$} = require 'atom-space-pen-views'
{CompositeDisposable, Disposable, TextBuffer} = require 'atom'

SelectNext = require './select-next'
{History, HistoryCycler} = require './history'
FindOptions = require './find-options'
BufferSearch = require './buffer-search'
FileIcons = require './file-icons'
FindView = require './find-view'
ProjectFindView = require './project-find-view'
ResultsModel = require './project/results-model'
ResultsPaneView = require './project/results-pane'

module.exports =
  activate: ({findOptions, findHistory, replaceHistory, pathsHistory}={}) ->
    # Convert old config setting for backward compatibility.
    if atom.config.get('find-and-replace.openProjectFindResultsInRightPane')
      atom.config.set('find-and-replace.projectSearchResultsPaneSplitDirection', 'right')
    atom.config.unset('find-and-replace.openProjectFindResultsInRightPane')

    atom.workspace.addOpener (filePath) ->
      new ResultsPaneView() if filePath is ResultsPaneView.URI

    @subscriptions = new CompositeDisposable
    @findHistory = new History(findHistory)
    @replaceHistory = new History(replaceHistory)
    @pathsHistory = new History(pathsHistory)

    @findOptions = new FindOptions(findOptions)
    @findModel = new BufferSearch(@findOptions)
    @resultsModel = new ResultsModel(@findOptions)

    @subscriptions.add atom.workspace.observeActivePaneItem (paneItem) =>
      if paneItem?.getBuffer?()
        @findModel.setEditor(paneItem)
      else
        @findModel.setEditor(null)

    @subscriptions.add atom.commands.add '.find-and-replace, .project-find', 'window:focus-next-pane', ->
      atom.views.getView(atom.workspace).focus()

    @subscriptions.add atom.commands.add 'atom-workspace', 'project-find:show', =>
      @createViews()
      showPanel @projectFindPanel, @findPanel, => @projectFindView.focusFindElement()

{'fraction_non_alphanumeric': 0.12678288431061807, 'fraction_numerical': 0.0, 'mean_word_length': 4.677661169415292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '2525637', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1072, 'n_words': 218}