Make `Highlight.draw` a 'simple' function
@@ -35,7 +35,7 @@ def on_finished_linting(buffer_id):
for view in views:
clear_view(view)
- highlights.draw(view)
+ draw(view, highlights.style_store, highlights.marks, highlights.lines)
def all_views_into_buffer(buffer_id):
@@ -128,7 +128,8 @@ class Highlight:
self.lines[error_type][line] = style
- def draw(self, view):
+
+def draw(view, style_store, marks, lines):
"""
Draw code and gutter marks in the given view.
@@ -142,15 +143,15 @@ class Highlight:
protected_regions = []
for error_type in WARN_ERR:
- if not self.marks[error_type]:
+ if not marks[error_type]:
continue
- for style, regions in self.marks[error_type].items():
- if not self.style_store.has_style(style):
+ for style, regions in marks[error_type].items():
+ if not style_store.has_style(style):
continue
- scope = self.style_store.get_val("scope", style, error_type)
- mark_style = self.style_store.get_val(
+ scope = style_store.get_val("scope", style, error_type)
+ mark_style = style_store.get_val(
"mark_style",
style,
error_type
@@ -169,21 +170,21 @@ class Highlight:
gutter_regions = {}
# collect regions of error type
- for line, style in self.lines[error_type].items():
- if not self.style_store.has_style(style):
+ for line, style in lines[error_type].items():
+ if not style_store.has_style(style):
continue
- pos = get_line_start(self.view, line)
+ pos = get_line_start(view, line)
region = sublime.Region(pos, pos)
gutter_regions.setdefault(style, []).append(region)
# draw gutter marks for
for style, regions in gutter_regions.items():
- icon = self.style_store.get_val("icon", style, error_type)
+ icon = style_store.get_val("icon", style, error_type)
if not icon or icon == "none": # do not draw icon
continue
if style_stores.GUTTER_ICONS.get('colorize', True) or icon in INBUILT_ICONS:
- scope = self.style_store.get_val("scope", style, error_type)
+ scope = style_store.get_val("scope", style, error_type)
else:
scope = " " # set scope to non-existent one
