def update_diagnostics_panel(window: sublime.Window):
assert window, "missing window!"
base_dir = get_project_path(window)
panel = ensure_diagnostics_panel(window)
assert panel, "must have a panel now!"
diagnostics_by_file = get_window_diagnostics(window)
if diagnostics_by_file is not None:
active_panel = window.active_panel()
is_active_panel = (active_panel == "output.diagnostics")
panel.settings().set("result_base_dir", base_dir)
panel.set_read_only(False)
if diagnostics_by_file:
to_render = []
for file_path, source_diagnostics in diagnostics_by_file.items():
relative_file_path = os.path.relpath(file_path, base_dir) if base_dir else file_path
if source_diagnostics:
to_render.append(format_diagnostics(relative_file_path, source_diagnostics))
panel.run_command("lsp_update_panel", {"characters": "\n".join(to_render)})
if settings.auto_show_diagnostics_panel and not active_panel:
window.run_command("show_panel",
{"panel": "output.diagnostics"})
else:
panel.run_command("lsp_clear_panel")
if settings.auto_show_diagnostics_panel and is_active_panel:
window.run_command("hide_panel",
{"panel": "output.diagnostics"})
panel.set_read_only(True)
评论列表
文章目录