Open torik42 opened 1 year ago
Further investigation revealed that the LaTeX Workshop extension sets the line nuber to NaN
for these problems. And after a quick web search, I understand that it is a valid value for typescript type number
, as required by @types/vscode
for Position.line
. But it should not be cast to null
by VSCode when sending the diagnostics to an LSP server. Maybe casting it to 0
is okay, because it is displayed in the first line anyway in VSCode.
Interestingly, VSCode sends this “faulty” diagnostic to the LSP server for Code Action Requests in all lines, even though it is displayed only in the first line.
@jrieken @mjbvz actually this sounds like a problem in VS Code itself and not LSP.
What happens is that an extension using the VS Code API directly creates a problem with line set to NaN
which when the diagnostic comes back in a code action request line is set to null
. I can filter them in LSP but I would argue that VS Code should not pass them to the code action request with null
. Best would be if VS Code already filters them when provided. The underlying problem might be that typeof NaN === 'number'
There is multiple issues here:
I don't believe we can change anything for 2 and 3 but anyone is invited to improve range validation
If VSCode somehow obtains faulty diagnostics, it also sends them – out of spec – to other LSP-servers in Code Action Requests. More specifically, it sends the position:
To my understanding, the line has to be
uinteger
but notnull
. This results in failing LSP servers.This specific issue might be fixed at the source of the faulty diagnostic. I have therefore created an issue in the LaTeX-Workshop extension. It turns out though, that they don’t use an LSP server, but the npm vscode module which requires the line to be of type
number
which allows for valueNaN
. Moreover, I think that VSCode should not send faulty LSP messages. For the case of diagnostics, it should either filter such diagnostics, which do not adhere to the LSP, or directly block them, when they are given to VSCode in the first place.Does this issue occur when all extensions are disabled?: (probably) No
Steps to Reproduce:
What I describe here, is how I noticed this error. I expect, that it can also appear in a lot of other contexts.
Open the following LaTeX file and build with xelatex.
This will issue two warnings with the faulty positions, they are displayed at the beginning of the file.
Edit: Added link and short comment about issue in LaTeX Workshop extension.