From 761c2c570446d73ecd2c87f5512fc5b7c9757e4f Mon Sep 17 00:00:00 2001 From: Tom van Ommeren Date: Mon, 16 Oct 2017 23:45:09 +0200 Subject: [PATCH] Remove preserve_whitespace Tabs as used in python docstrings are not Markdown, work with python language server to improve hovers --- plugin/core/popups.py | 7 ------- plugin/hover.py | 4 ++-- plugin/signature_help.py | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/plugin/core/popups.py b/plugin/core/popups.py index 2ea2c55cb..2c623124e 100644 --- a/plugin/core/popups.py +++ b/plugin/core/popups.py @@ -14,10 +14,3 @@ font-family: system; } ''' - - -def preserve_whitespace(contents: str) -> str: - """Preserve indentation in (non-markdown) ascii docstrings (e.g. pyls)""" - contents = contents.replace('\t', '\u00A0' * 4) - contents = contents.replace(' ', '\u00A0' * 2) - return contents diff --git a/plugin/hover.py b/plugin/hover.py index 77d5d7bb2..5991e509a 100644 --- a/plugin/hover.py +++ b/plugin/hover.py @@ -8,7 +8,7 @@ from .core.protocol import Request from .core.documents import get_document_position from .core.logging import debug -from .core.popups import preserve_whitespace, popup_css, popup_class +from .core.popups import popup_css, popup_class SUBLIME_WORD_MASK = 515 NO_HOVER_SCOPES = 'comment, constant, keyword, storage, string' @@ -95,7 +95,7 @@ def show_hover(self, point, contents): if language: formatted.append("```{}\n{}\n```\n".format(language, value)) else: - formatted.append(preserve_whitespace(value)) + formatted.append(value) mdpopups.show_popup( self.view, diff --git a/plugin/signature_help.py b/plugin/signature_help.py index 98d61628f..d00b3cae5 100644 --- a/plugin/signature_help.py +++ b/plugin/signature_help.py @@ -14,7 +14,7 @@ from .core.configurations import is_supported_syntax, config_for_scope from .core.protocol import Request from .core.logging import debug -from .core.popups import preserve_whitespace, popup_css, popup_class +from .core.popups import popup_css, popup_class class SignatureHelpListener(sublime_plugin.ViewEventListener): @@ -147,4 +147,4 @@ def _build_popup_content(self) -> str: sigDocs = signature.get('documentation', None) if sigDocs: formatted.append(sigDocs) - return preserve_whitespace("\n".join(formatted)) + return "\n".join(formatted)