Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
x/tools/gopls: unexpected line/character calculations in certain diagnostics #40522
What did you do?
I've run into a situation where gopls was consistently returning a diagnostic with range data that was inconsistent with the editor state. Critically, it was producing a range with a character that was past the end of the line.
While I uncovered the issue interacting with gopls via the LSP interface, it appears to exhibit the behavior on the command line as well. Here's the code that reproduces the issue for me:
What did you expect to see?
The line at issue, which has an intentional error, is the
However if I exchange that offending semi-colon for an
Not only is the line change surprising, the character offset is past the end of the line.
What did you see instead?
I would have expected the line/character output to be unchanged, or changed, but still consistent with the length of the line in question.