<commit_before>import sublime
from sublime_plugin import TextCommand, EventListener

from ..git_command import GitCommand


class GsStatusBarEventListener(EventListener):

    def on_new(self, view):
        view.run_command("gs_update_status_bar")

    def on_load(self, view):
        view.run_command("gs_update_status_bar")

    def on_activated(self, view):
        view.run_command("gs_update_status_bar")

    def on_post_save(self, view):
        view.run_command("gs_update_status_bar")


class GsUpdateStatusBarCommand(TextCommand, GitCommand):

    """
    Update the short Git status in the Sublime status bar.
    """

    def run(self, edit):
        if sublime.load_settings("GitSavvy.sublime-settings").get("git_status_in_status_bar"):
            sublime.set_timeout_async(self.run_async, 0)

    def run_async(self):
        # Short-circuit update attempts for files not part of Git repo.
        if not self._repo_path(throw_on_stderr=False):
            self.view.erase_status("gitsavvy-repo-status")
            return

        short_status = self.get_branch_status_short()
        self.view.set_status("gitsavvy-repo-status", short_status)<commit_msg>Fix: Annoying error when opening new window, due to status bar changes.<commit_after>import sublime
from sublime_plugin import TextCommand, EventListener

from ..git_command import GitCommand


class GsStatusBarEventListener(EventListener):

    def on_new(self, view):
        view.run_command("gs_update_status_bar")

    def on_load(self, view):
        view.run_command("gs_update_status_bar")

    def on_activated(self, view):
        view.run_command("gs_update_status_bar")

    def on_post_save(self, view):
        view.run_command("gs_update_status_bar")


class GsUpdateStatusBarCommand(TextCommand, GitCommand):

    """
    Update the short Git status in the Sublime status bar.
    """

    def run(self, edit):
        if sublime.load_settings("GitSavvy.sublime-settings").get("git_status_in_status_bar"):
            sublime.set_timeout_async(self.run_async, 0)

    def run_async(self):
        # Short-circuit update attempts for files not part of Git repo.
        if not self.file_path or self._repo_path(throw_on_stderr=False):
            self.view.erase_status("gitsavvy-repo-status")
            return

        short_status = self.get_branch_status_short()
        self.view.set_status("gitsavvy-repo-status", short_status)
{'fraction_non_alphanumeric': 0.09248554913294797, 'fraction_numerical': 0.0008257638315441783, 'mean_word_length': 3.606463878326996, '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': '1975817', 'n_tokens_mistral': 770, 'n_tokens_neox': 736, 'n_words': 152}