pappasam / jedi-language-server

A Python language server exclusively for Jedi. If Jedi supports it well, this language server should too.
MIT License
574 stars 44 forks source link

`lsp_python_diagnostic` may use invalid `lsprotocol.types.Position.character` #272

Closed seeM closed 7 months ago

seeM commented 1 year ago

Due to a bug in CPython (https://github.com/python/cpython/issues/105911), the lsp_python_diagnostic function may encounter a value of err.offset = 0 (instead of the 1-indexed value guaranteed in the Python docs). If so, it will try to create an lsprotocol.types.Position with character=-1 causing a validation error.

I believe the caret would be at the correct position if we do something like err.offset = max(err.offset, 0) but I haven't tested that thoroughly.