Skip to content

Commit

Permalink
Refactor: Only two types of hover text
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kghose committed Nov 16, 2020
1 parent a363703 commit 3630ec9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion benten/code/intelligence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions benten/langserver/lspobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3630ec9

Please sign in to comment.