diff --git a/python/helpers/pydev/_pydev_bundle/pydev_ipython_rich_output.py b/python/helpers/pydev/_pydev_bundle/pydev_ipython_rich_output.py index 1ad1dc3ba5bd..7d9626cce53e 100644 --- a/python/helpers/pydev/_pydev_bundle/pydev_ipython_rich_output.py +++ b/python/helpers/pydev/_pydev_bundle/pydev_ipython_rich_output.py @@ -12,10 +12,7 @@ class PyDevDisplayHook(DisplayHook): super(PyDevDisplayHook, self).write_format_data(format_dict, *args, **kwargs) return - if "text/plain" in format_dict: - text = format_dict["text/plain"] - if len(text) > 0 and not text.endswith("\n"): - format_dict["text/plain"] = text + "\n" + add_new_line_to_text(format_dict) format_dict["execution_count"] = str(self.shell.execution_count) send_rich_output(format_dict) @@ -26,9 +23,17 @@ class PyDevDisplayPub(DisplayPublisher): if not is_supported(data): super(PyDevDisplayPub, self).publish(data, *args, **kwargs) return + add_new_line_to_text(data) send_rich_output(data) +def add_new_line_to_text(format_dict): + if "text/plain" in format_dict: + text = format_dict["text/plain"] + if len(text) > 0 and not text.endswith("\n"): + format_dict["text/plain"] = text + "\n" + + def is_supported(data): for type in data.keys(): if type not in ("text/plain", "image/png", "text/html"):