Restrict showing viewport marker
The view has more than x errors
Not all of these errors are currently in the viewport
@@ -565,15 +565,18 @@ def scroll_into_view(panel, wanted_lines, errors):
scroll_to_line(panel, vtop, animate=not out_of_bounds)
+CONFUSION_THRESHOLD = 5
+
+
def mark_visible_viewport(panel, view, errors):
# type: (sublime.View, sublime.View, List[Dict[str, Any]]) -> None
KEY = 'SL.Panel.ViewportMarker'
KEY2 = 'SL.Panel.ViewportMarker2'
+ if len(errors) > CONFUSION_THRESHOLD:
viewport = view.visible_region()
-
visible_errors = [e for e in errors if viewport.contains(e['region'])]
- if visible_errors:
+ if visible_errors and len(visible_errors) != len(errors):
head, end = visible_errors[0], visible_errors[-1]
head_line = panel.text_point(head['panel_line'] - 1, 0)
end_line = panel.text_point(end['panel_line'], 0)
@@ -593,7 +596,8 @@ def mark_visible_viewport(panel, view, errors):
end_line = panel.text_point(end['panel_line'] + 1, 0)
regions = [sublime.Region(r.a, r.a + 1) for r in panel.lines(sublime.Region(head_line, end_line))]
panel.add_regions(KEY2, regions, scope=scope, flags=flags)
- else:
+ return
+
panel.erase_regions(KEY)
panel.erase_regions(KEY2)
