Skip to content

Commit e5804fd

Browse files
committed
Hover uses Script.help, not Script.infer
1 parent 19317db commit e5804fd

3 files changed

Lines changed: 17 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 0.5.1
8+
9+
### Changed
10+
11+
- Hover uses Jedi's `help` method, instead of `infer`. Provides better help message information.
12+
713
## 0.5.0
814

915
### Added

jedi_language_server/server.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
@SERVER.feature(COMPLETION, triggerCharacters=["."])
4646
def lsp_completion(server: LanguageServer, params: CompletionParams):
47-
"""Returns completion items."""
47+
"""Returns completion items"""
4848
script = get_jedi_script(server, params.textDocument.uri)
4949
jedi_completions = script.complete(
5050
line=params.position.line + 1, column=params.position.character,
@@ -83,16 +83,17 @@ def lsp_definition(
8383
def lsp_hover(
8484
server: LanguageServer, params: TextDocumentPositionParams
8585
) -> Hover:
86-
"""Support the hover feature"""
86+
"""Support Hover"""
8787
script = get_jedi_script(server, params.textDocument.uri)
88-
names = script.infer(
89-
line=params.position.line + 1, column=params.position.character,
90-
)
91-
return Hover(
92-
contents=(
93-
names[0].docstring() if names else "No docstring definition found."
88+
try:
89+
_names = script.help(
90+
line=params.position.line + 1, column=params.position.character,
9491
)
95-
)
92+
except Exception: # pylint: disable=broad-except
93+
names = [] # type: List[str]
94+
else:
95+
names = [name for name in (n.docstring() for n in _names) if name]
96+
return Hover(contents=names if names else "jedi: no help docs found")
9697

9798

9899
@SERVER.feature(REFERENCES)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include_trailing_comma = true
1313

1414
[tool.poetry]
1515
name = "jedi-language-server"
16-
version = "0.5.0"
16+
version = "0.5.1"
1717
description = "A language server for Jedi!"
1818
authors = ["Sam Roeca <samuel.roeca@gmail.com>"]
1919
readme = "README.md"

0 commit comments

Comments
 (0)