LSP: textDocument/codeAction CodeActionParams with wrong Range

I’m implementing a LSP extension for Nova. And it seems that there is a bug of CodeActionParams of textDocument/codeAction, which is a request sent by the client to the language server.

When I modify the last line of a file (let’s say there are n lines in the file), the client will send a textDocument/codeAction request, the type of the params of the method is CodeActionParams . And in the params, the range field seems to start from 1 instead of starting from 0, which will cause out-of-range error for me.

According to the LSP specification (Range), the position of the range should be zero-based.


Update

It seems that the users of the Python extension also observe similar problems (see: link):

Autocomplete broken while typing on the last editor line

I don’t know if this issue is connected to this other line end issue, but it’s also cropping up with the Rust Analyzer language server and causing a panic/server crash. Here’s a report from a user (which I easily replicated):

As you can see from the logs in the bug report, it’s the same textDocument/codeAction out of bounds error. Interestingly, the user report (and my testing) also show the same “out of bounds” error for textDocument/completion CompletionParams immediately afterwards (which is what made me think of the other bug report linked above).

I’m also seeing this in the textDocument/didChange notification. When typing on an empty last line of a document, the first character has the correct line number in contentChanges.range, but subsequent characters have a line number that’s 1 too high and a character value of 0.