Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.34.1 broke completion at the beginning of a line #162

Closed
pyscripter opened this issue Sep 22, 2021 · 0 comments
Closed

Version 0.34.1 broke completion at the beginning of a line #162

pyscripter opened this issue Sep 22, 2021 · 0 comments

Comments

@pyscripter
Copy link
Contributor

pyscripter commented Sep 22, 2021

Commit e4226c3 was meant to fix hover at the beginning of the line. It contains the following line in jedi_utils.py:

character = 1 if position.character == 0 else position.character

However this breaks code completion (and possibly other features) at the beginning of the line.

If the line is empty you get the following traceback instead of getting the list for the beginning of the line (globals, builtins, etc.) . e.g.

ERROR:pygls.protocol:Failed to handle request 15 textDocument/completion partial_result_token=None work_done_token=None text_document=TextDocumentIdentifier(uri='file:///C:/Users/kiria/Desktop/test.py') position=13:0 context=None
Traceback (most recent call last):
  File "C:\ProgramData\PyScripter\Lsp\jls\jedilsp\pygls\protocol.py", line 331, in _handle_request
    self._execute_request(msg_id, handler, params)
  File "C:\ProgramData\PyScripter\Lsp\jls\jedilsp\pygls\protocol.py", line 260, in _execute_request
    method_name, method_type, msg_id, handler(params))
  File "C:\ProgramData\PyScripter\Lsp\jls\jedilsp\jedi_language_server\server.py", line 190, in completion
    completions_jedi = jedi_script.complete(**jedi_lines)
  File "C:\ProgramData\PyScripter\Lsp\jls\jedilsp\jedi\api\helpers.py", line 485, in wrapper
    raise ValueError('`column` parameter (%d) is not in a valid range '
ValueError: `column` parameter (1) is not in a valid range (0-0) for line 14 ('\r\n').

If there is a character at the beginning of the line you get wrong completion for character position 1 instead of 0.

I also suspect that there is a logic error a couple of lines below:

column=min(character, line_length - 1 if line_length else 0),

It does not account for Windows line endings '\r\n' which are two characters long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant