x/tools/internal/lsp/cache: improve method of getting end positions for errors #37936
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
help wanted
Tools
This label describes issues relating to any tools in the x/tools repository.
When we calculate end positions for errors that originate from go/packages. We do some kind of syntax analysis, but some issues arise when adding new characters to the list in internal/lsp/cache/errors.go#L208
Take the sample program below:
We will have two errors: (1) "undeclared name: y" and (2) "could not import golang.org/whatever (no package for import golang.org/whatever)".
In the current state, the diagnostic for error 1 will be on "y+2" and the diagnostic for error 2 will be on "golang.org/whatever".
Now, the diagnostic for error 1 should only underline "y" since that is the undeclared name, to fix this I could add "/" to the character list in internal/lsp/cache/errors.go#L208 but then the diagnostic on error 2 would now underline "golang.org" rather than "golang.org/whatever".
I think gopls needs a better way to compute the end positions for type errors.
The text was updated successfully, but these errors were encountered: