Skip to content

Commit

Permalink
remove unnecessary workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Jul 29, 2023
1 parent d4ea5bc commit 8a54935
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 74 deletions.
4 changes: 2 additions & 2 deletions jedi_language_server/jedi_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ def lsp_python_diagnostic(uri: str, source: str) -> Optional[Diagnostic]:
def line_column(position: Position) -> Tuple[int, int]:
"""Translate pygls Position to Jedi's line/column.
Returns a dictionary because this return result should be unpacked as a
function argument to Jedi's functions.
Returns a tuple because this return result should be unpacked as a function
argument to Jedi's functions.
Jedi is 1-indexed for lines and 0-indexed for columns. LSP is 0-indexed for
lines and 0-indexed for columns. Therefore, add 1 to LSP's request for the
Expand Down
9 changes: 1 addition & 8 deletions jedi_language_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,14 @@ def hover(
jedi_script = jedi_utils.script(server.project, document)
jedi_lines = jedi_utils.line_column(params.position)
markup_kind = _choose_markup(server)
# jedi's help function is buggy when the column is 0. For this reason, as a
# rote fix, we simply set the column to 1 if params.position returns column
# 0.
hover_text = jedi_utils.hover_text(
jedi_script.help(
line=jedi_lines[0],
column=1 if jedi_lines[1] == 0 else jedi_lines[1],
),
jedi_script.help(*jedi_lines),
markup_kind,
server.initialization_options,
)
if not hover_text:
return None
contents = MarkupContent(kind=markup_kind, value=hover_text)
document = server.workspace.get_document(params.text_document.uri)
_range = pygls_utils.current_word_range(document, params.position)
return Hover(contents=contents, range=_range)

Expand Down
Loading

0 comments on commit 8a54935

Please sign in to comment.