Skip to content

Commit

Permalink
Filter diagnostics while rendering panel output
Browse files Browse the repository at this point in the history
  • Loading branch information
tomv564 authored and rwols committed Nov 9, 2018
1 parent 6f690da commit 03acb77
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions plugin/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,11 @@ def update_diagnostics_panel(window: sublime.Window):
except ValueError:
relative_file_path = file_path
if source_diagnostics:
to_render.append(format_diagnostics(relative_file_path, source_diagnostics))
if not auto_open_panel:
auto_open_panel = has_relevant_diagnostics(source_diagnostics)
formatted = format_diagnostics(relative_file_path, source_diagnostics)
if formatted:
to_render.append(formatted)
if not auto_open_panel:
auto_open_panel = has_relevant_diagnostics(source_diagnostics)

panel.set_read_only(False)
panel.run_command("lsp_update_panel", {"characters": "\n".join(to_render)})
Expand Down Expand Up @@ -335,9 +337,13 @@ def has_relevant_diagnostics(origin_diagnostics):


def format_diagnostics(file_path, origin_diagnostics):
content = " ◌ {}:\n".format(file_path)
content = ""
for origin, diagnostics in origin_diagnostics.items():
for diagnostic in diagnostics:
item = format_diagnostic(diagnostic)
content += item + "\n"
return content
if diagnostic.severity <= settings.show_diagnostics_severity_level:
item = format_diagnostic(diagnostic)
content += item + "\n"
if content:
return " ◌ {}:\n{}".format(file_path, content)
else:
return None

0 comments on commit 03acb77

Please sign in to comment.