def destroy_output_panels(window: sublime.Window) -> None: for field in filter(lambda a: not a.startswith('__'), PanelName.__dict__.keys()): panel_name = getattr(PanelName, field) panel = window.find_output_panel(panel_name) if panel and panel.is_valid(): panel.settings().set("syntax", "Packages/Text/Plain text.tmLanguage") window.destroy_output_panel(panel_name)
def update_diagnostics_panel(window: sublime.Window): assert window, "missing window!" if not window.is_valid(): debug('ignoring update to closed window') return base_dir = get_project_path(window) 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") if diagnostics_by_file: panel = ensure_diagnostics_panel(window) assert panel, "must have a panel now!" panel.settings().set("result_base_dir", base_dir) auto_open_panel = False to_render = [] for file_path, source_diagnostics in diagnostics_by_file.items(): try: relative_file_path = os.path.relpath( file_path, base_dir) if base_dir else file_path except ValueError: relative_file_path = file_path if 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)}) panel.set_read_only(True) if settings.auto_show_diagnostics_panel and not active_panel: if auto_open_panel: window.run_command("show_panel", {"panel": "output.diagnostics"}) else: panel = window.find_output_panel("diagnostics") if panel: panel.run_command("lsp_clear_panel") if is_active_panel: window.run_command("hide_panel", {"panel": "output.diagnostics"})
def __init__( self, window: sublime.Window, name: str, *, force_writes: bool = False, follow_cursor: bool = False ): view = window.find_output_panel(name) if view is None: raise ValueError('Output panel "%s" does not exist.' % name) ViewStream.__init__(self, view, force_writes=force_writes, follow_cursor=follow_cursor) Panel.__init__(self, window, "output." + name) self.name = name
def ensure_diagnostics_panel(window: sublime.Window): return window.find_output_panel("diagnostics") or create_diagnostics_panel( window)
def ensure_references_panel(window: sublime.Window): return window.find_output_panel("references") or create_references_panel(window)
def ensure_references_panel(window: sublime.Window): return window.find_output_panel("references") or create_references_panel(window)
def ensure_diagnostics_panel(window: sublime.Window): return window.find_output_panel("diagnostics") or create_diagnostics_panel(window)
def ensure_panel(window: sublime.Window, name: str, result_file_regex: str, result_line_regex: str, syntax: str) -> Optional[sublime.View]: return window.find_output_panel(name) or create_panel( window, name, result_file_regex, result_line_regex, syntax)
def ensure_terminus_repl(window: sublime.Window): if not window.find_output_panel(JULIA_REPL_NAME): start_terminus_repl(window, False) return False return True