<commit_before>{CompositeDisposable} = require 'event-kit'
MinimapFindAndReplaceBinding = null

module.exports =
  active: false
  bindingsById: {}
  subscriptionsById: {}

  isActive: -> @active

  activate: (state) ->
    @subscriptions = new CompositeDisposable

  consumeMinimapServiceV1: (@minimap) ->
    @minimap.registerPlugin 'find-and-replace', this

  deactivate: ->
    @minimap.unregisterPlugin 'find-and-replace'
    @minimap = null

  activatePlugin: ->
    return if @active

    @active = true

    @subscriptions.add @minimap.observeMinimaps (minimap) =>
      MinimapFindAndReplaceBinding ?= require './minimap-find-and-replace-binding'

      binding = new MinimapFindAndReplaceBinding(minimap)
      @bindingsById[minimap.id] = binding

      @subscriptionsById[minimap.id] = minimap.onDidDestroy =>
        @subscriptionsById[minimap.id].dispose()
        @bindingsById[minimap.id].destroy()

        delete @bindingsById[minimap.id]
        delete @subscriptionsById[minimap.id]<commit_msg>:guardsman: Guard against accessing destroyed binding<commit_after>{CompositeDisposable} = require 'event-kit'
MinimapFindAndReplaceBinding = null

module.exports =
  active: false
  bindingsById: {}
  subscriptionsById: {}

  isActive: -> @active

  activate: (state) ->
    @subscriptions = new CompositeDisposable

  consumeMinimapServiceV1: (@minimap) ->
    @minimap.registerPlugin 'find-and-replace', this

  deactivate: ->
    @minimap.unregisterPlugin 'find-and-replace'
    @minimap = null

  activatePlugin: ->
    return if @active

    @active = true

    @subscriptions.add @minimap.observeMinimaps (minimap) =>
      MinimapFindAndReplaceBinding ?= require './minimap-find-and-replace-binding'

      binding = new MinimapFindAndReplaceBinding(minimap)
      @bindingsById[minimap.id] = binding

      @subscriptionsById[minimap.id] = minimap.onDidDestroy =>
        @subscriptionsById[minimap.id]?.dispose()
        @bindingsById[minimap.id]?.destroy()

        delete @bindingsById[minimap.id]
        delete @subscriptionsById[minimap.id]
{'fraction_non_alphanumeric': 0.11411992263056092, 'fraction_numerical': 0.0009671179883945841, 'mean_word_length': 3.8341121495327104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '4422161', 'n_tokens_mistral': 681, 'n_tokens_neox': 658, 'n_words': 108}