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

Error on empty lines #327

Open
Fildo7525 opened this issue Nov 25, 2024 · 3 comments
Open

Error on empty lines #327

Fildo7525 opened this issue Nov 25, 2024 · 3 comments

Comments

@Fildo7525
Copy link

After opening a document

image

I use:
NVIM v0.11.0-dev-1228+g9e7b0bcf51
Build type: RelWithDebInfo
LuaJIT 2.1.1731601260
Run "nvim -V1 -v" for more inf

lsp version:
jedi-language-server jedi_language_server
A Python language server exclusively for Jedi. If Jedi supports it well, this language server should too.

  installed version 0.42.0                                           
  homepage          https://github.com/pappasam/jedi-language-server 
  languages         Python                                           
  categories        LSP                                              
  executables       jedi-language-server                             
lsp_signatur handler RPC[Error] code_name = InternalError, message = "ValueError: `column` parameter (1) is not in a valid range (0-0) for line 95 ('\\n')." data = {
  traceback = { '  File "/home/fildo7525/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.10/site-packages/pygls/protocol/json_rpc.py", line 266, in _h
andle_request\n    self._execute_request(msg_id, handler, params)\n', '  File "/home/fildo7525/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.10/site
-packages/pygls/protocol/json_rpc.py", line 188, in _execute_request\n    self._send_response(msg_id, handler(params))\n', '  File "/home/fildo7525/.local/share/nvim/mason/p
ackages/jedi-language-server/venv/lib/python3.10/site-packages/jedi_language_server/server.py", line 284, in signature_help\n    signatures_jedi = jedi_script.get_signatures
(*jedi_lines)\n', "  File \"/home/fildo7525/.local/share/nvim/mason/packages/jedi-language-server/venv/lib/python3.10/site-packages/jedi/api/helpers.py\", line 484, in wrapp
er\n    raise ValueError('`column` parameter (%d) is not in a valid range '\n" }
}
@dimbleby
Copy link
Contributor

dimbleby commented Jan 1, 2025

Position comes from the client so this looks like a client error. Though this works fine for me - and presumably also for everyone else.

@davidhalter
Copy link

I'm not sure that is the case. I thought jedi-language-server had solved this internally. But AFAIK LSP allows character positions bigger than the line length: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position

It's a bit sub-optimal that Jedi doesn't allow for this. Maybe we should just allow this within Jedi?

But then again it really looks like the client is wrong here, because within VIM character positions should always be "valid" positions. (At least AFAIK)

@dimbleby
Copy link
Contributor

dimbleby commented Jan 1, 2025

I dont think jedi-language-server does anything about over-large character values - results from

def line_column(position: Position) -> Tuple[int, int]:
"""Translate pygls Position to Jedi's line/column.
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
line.
Note: as of version 3.15, LSP's treatment of "position" conflicts with
Jedi in some cases. According to the LSP docs:
Character offset on a line in a document (zero-based). Assuming that
the line is represented as a string, the `character` value represents
the gap between the `character` and `character + 1`.
Sources:
https://microsoft.github.io/language-server-protocol/specification#position
https://github.com/palantir/python-language-server/pull/201/files
"""
return (position.line + 1, position.character)
are used un-fixed so far as I can see.

I agree that the spec seems to require language servers to tolerate such things, and my unconsidered hot take would be that it makes sense for that to happen in jedi rather than making this project do the work.

However I also agree that it looks as though the client is wrong - and as a vim user I have never seen this myself (and do not reproduce it now).

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

No branches or pull requests

3 participants