Repository: sublimelinter/sublimelinter
Issue: Status bar busy indicator stops on first response from backend

We only fire 'BEGIN_LINTING' and 'FINISHED_LINTING'. But since #887 the responses fly in as soon as possible. Currently all responses fire 'FINISHED_LINTING'. 

We need three events here

'START_LINTING(bid)' -> 'LINT_RESULT(bid, linter, errors)' -> 'STOP_LINTING(bid [,errors])'

Feel free to bike-shed the naming here.

Changed files:
sublime_linter.py, highlight_view.py, panel_view.py, busy_indicator_view.py, status_bar_view.py, lint/events.py

diff --git a/busy_indicator_view.py b/busy_indicator_view.py
index ccb63c9..c0dac53 100644
--- a/busy_indicator_view.py
+++ b/busy_indicator_view.py
@@ -7,7 +7,7 @@ from .lint.const import STATUS_BUSY_KEY
 from .lint import events
 
 
-INITIAL_DELAY = 1
+INITIAL_DELAY = 2
 CYCLE_TIME = 200
 TIMEOUT = 20
 
@@ -29,7 +29,7 @@ def plugin_unloaded():
     events.off(on_finished_linting)
 
 
-@events.on(events.BEGIN_LINTING)
+@events.on(events.LINT_START)
 def on_begin_linting(buffer_id):
     State['running'][buffer_id] = time.time()
 
@@ -38,7 +38,7 @@ def on_begin_linting(buffer_id):
         sublime.set_timeout_async(lambda: draw(**State), INITIAL_DELAY * 1000)
 
 
-@events.on(events.FINISHED_LINTING)
+@events.on(events.LINT_END)
 def on_finished_linting(buffer_id, **kwargs):
     State['running'].pop(buffer_id, None)
 
diff --git a/highlight_view.py b/highlight_view.py
index 155390f..847d9fe 100644
--- a/highlight_view.py
+++ b/highlight_view.py
@@ -38,11 +38,11 @@ def clear_view(view):
 
 
 def plugin_unloaded():
-    events.off(on_finished_linting)
+    events.off(on_lint_result)
 
 
-@events.on(events.FINISHED_LINTING)
-def on_finished_linting(buffer_id, linter_name, **kwargs):
+@events.on(events.LINT_RESULT)
+def on_lint_result(buffer_id, linter_name, **kwargs):
     views = list(all_views_into_buffer(buffer_id))
     if not views:
         return
diff --git a/lint/events.py b/lint/events.py
index 5f2f413..21fa805 100644
--- a/lint/events.py
+++ b/lint/events.py
@@ -2,8 +2,9 @@ from collections import defaultdict
 import traceback
 
 
-BEGIN_LINTING = 'BEGIN_LINTING'
-FINISHED_LINTING = 'FINISHED_LINTING'
+LINT_START = 'LINT_START'    # (buffer_id)
+LINT_RESULT = 'LINT_RESULT'  # (buffer_id, linter_name, errors)
+LINT_END = 'LINT_END'        # (buffer_id)
 
 
 listeners = defaultdict(set)
diff --git a/panel_view.py b/panel_view.py
index 2d3b856..25ed95b 100644
--- a/panel_view.py
+++ b/panel_view.py
@@ -35,11 +35,11 @@ def plugin_loaded():
 
 
 def plugin_unloaded():
-    events.off(on_finished_linting)
+    events.off(on_lint_result)
 
 
-@events.on(events.FINISHED_LINTING)
-def on_finished_linting(buffer_id, **kwargs):
+@events.on(events.LINT_RESULT)
+def on_lint_result(buffer_id, **kwargs):
     for window in sublime.windows():
         if buffer_id in buffer_ids_per_window(window):
             fill_panel(window, update=True)
diff --git a/status_bar_view.py b/status_bar_view.py
index 76159ff..89e9562 100644
--- a/status_bar_view.py
+++ b/status_bar_view.py
@@ -23,11 +23,11 @@ def plugin_loaded():
 
 
 def plugin_unloaded():
-    events.off(on_finished_linting)
+    events.off(on_lint_result)
 
 
-@events.on(events.FINISHED_LINTING)
-def on_finished_linting(buffer_id, **kwargs):
+@events.on(events.LINT_RESULT)
+def on_lint_result(buffer_id, **kwargs):
     active_view = State['active_view']
     if active_view.buffer_id() == buffer_id:
         State.update({
diff --git a/sublime_linter.py b/sublime_linter.py
index 09feefc..82c0454 100644
--- a/sublime_linter.py
+++ b/sublime_linter.py
@@ -229,11 +229,13 @@ class SublimeLinter(sublime_plugin.EventListener, Listener):
         if not view:
             return
 
-        events.broadcast(events.BEGIN_LINTING, {'buffer_id': view.buffer_id()})
+        events.broadcast(events.LINT_START, {'buffer_id': view.buffer_id()})
 
         next = partial(self.highlight, view, hit_time)
         backend.lint_view(view, hit_time, next)
 
+        events.broadcast(events.LINT_END, {'buffer_id': view.buffer_id()})
+
     def highlight(self, view, hit_time, linter, errors):
         """
         Highlight any errors found during a lint of the given view.
@@ -255,7 +257,7 @@ class SublimeLinter(sublime_plugin.EventListener, Listener):
                       if error['linter'] != linter.name] + errors
         persist.errors[bid] = all_errors
 
-        events.broadcast(events.FINISHED_LINTING, {
+        events.broadcast(events.LINT_RESULT, {
             'buffer_id': bid,
             'linter_name': linter.name,
             'errors': errors