<commit_before>import sublime
import sublime_plugin

import time

from .lint import events


INITIAL_DELAY = 2
CYCLE_TIME = 200
TIMEOUT = 20
STATUS_BUSY_KEY = "sublime_linter_status_busy"

State = {
    'active_view': None,
    'running': {}
}


def plugin_loaded():
    State.update({
        'active_view': sublime.active_window().active_view()
    })


def plugin_unloaded():
    events.off(on_begin_linting)
    events.off(on_finished_linting)


@events.on(events.LINT_START)
def on_begin_linting(buffer_id):
    State['running'][buffer_id] = time.time()

    active_view = State['active_view']
    if active_view.buffer_id() == buffer_id:
        sublime.set_timeout_async(lambda: draw(**State), INITIAL_DELAY * 1000)


@events.on(events.LINT_END)
def on_finished_linting(buffer_id, **kwargs):
    State['running'].pop(buffer_id, None)

    active_view = State['active_view']
    if active_view.buffer_id() == buffer_id:
        draw(**State)


class UpdateState(sublime_plugin.EventListener):
    def on_activated_async(self, active_view):
        State.update({
            'active_view': active_view
        })

        draw(**State)

<commit_msg>clear busy indicator on unload<commit_after>import sublime
import sublime_plugin

import time

from .lint import events


INITIAL_DELAY = 2
CYCLE_TIME = 200
TIMEOUT = 20
STATUS_BUSY_KEY = "sublime_linter_status_busy"

State = {
    'active_view': None,
    'running': {}
}


def plugin_loaded():
    State.update({
        'active_view': sublime.active_window().active_view()
    })


def plugin_unloaded():
    events.off(on_begin_linting)
    events.off(on_finished_linting)
    for window in sublime.windows():
        for view in window.views():
            view.erase_status(STATUS_BUSY_KEY)


@events.on(events.LINT_START)
def on_begin_linting(buffer_id):
    State['running'][buffer_id] = time.time()

    active_view = State['active_view']
    if active_view.buffer_id() == buffer_id:
        sublime.set_timeout_async(lambda: draw(**State), INITIAL_DELAY * 1000)


@events.on(events.LINT_END)
def on_finished_linting(buffer_id, **kwargs):
    State['running'].pop(buffer_id, None)

    active_view = State['active_view']
    if active_view.buffer_id() == buffer_id:
        draw(**State)


class UpdateState(sublime_plugin.EventListener):
    def on_activated_async(self, active_view):
        State.update({
            'active_view': active_view
        })

        draw(**State)


{'fraction_non_alphanumeric': 0.11973845525132816, 'fraction_numerical': 0.008173273395995096, 'mean_word_length': 3.8862275449101795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2844688', 'n_tokens_mistral': 873, 'n_tokens_neox': 823, 'n_words': 145}