From 3630ec919a7b87744799f083555150c0fdda36f8 Mon Sep 17 00:00:00 2001 From: C02CR2E3ML85 Date: Sun, 15 Nov 2020 22:19:14 -0500 Subject: [PATCH] Refactor: Only two types of hover text Simpify code by implementing only two types of hover text "code" and "markdown". The code text is enclosed in backticks so that it appears as code when displayed by VS Code. --- benten/code/intelligence.py | 2 +- benten/langserver/lspobjects.py | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/benten/code/intelligence.py b/benten/code/intelligence.py index eeb244f..08d4c80 100644 --- a/benten/code/intelligence.py +++ b/benten/code/intelligence.py @@ -36,7 +36,7 @@ def completion(self): return [CompletionItem(label=c) for c in self._completions] def hover(self): - return Hover(self.doc, hover_type=Hover.HoverType.CWLdoc) + return Hover(self.doc, hover_type=Hover.HoverType.Markdown) def definition(self): pass diff --git a/benten/langserver/lspobjects.py b/benten/langserver/lspobjects.py index 2fb2bae..64a5088 100644 --- a/benten/langserver/lspobjects.py +++ b/benten/langserver/lspobjects.py @@ -240,23 +240,19 @@ class Hover(LSPObject): class HoverType(IntEnum): Markdown = 1 Code = 2 - CWLdoc = 3 - def __init__(self, contents, _range=None, hover_type: HoverType = HoverType.Markdown): + def __init__(self, contents, _range=None, + hover_type: HoverType = HoverType.Markdown): if hover_type == Hover.HoverType.Code: self.contents = MarkupContent( kind="markdown", value="```\n" + contents + "\n```" ) - elif hover_type == Hover.HoverType.Markdown: + else: self.contents = MarkupContent( kind="markdown", value=contents ) - elif hover_type == Hover.HoverType.CWLdoc: - # For unknown reasons (2020.06) if we pass the CWL docs as a MarkupContent - # object, VS Code fails to render it. Passing as a plain string works fine - self.contents = contents self.range = _range