gopls/internal/lsp/cache: allow "" or "null" Diagnostics.Data

The previous code would attempt to decode both of these
as JSON quick-fixes, which would fail. (At least, we assume
that was the cause of the attached field report.)

Fixes golang/go#64503

Change-Id: Id705c6700d601ebf4720e1f749a1594244ffea9c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/549575
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Alan Donovan 2023-12-13 16:49:05 -05:00
Родитель 20e1bb71f6
Коммит 1346c45ee1
1 изменённых файлов: 4 добавлений и 1 удалений

5
gopls/internal/lsp/cache/diagnostics.go поставляемый
Просмотреть файл

@ -149,7 +149,10 @@ func BundleQuickFixes(sd *Diagnostic) bool {
// BundledQuickFixes extracts any bundled codeActions from the
// diag.Data field.
func BundledQuickFixes(diag protocol.Diagnostic) []protocol.CodeAction {
if diag.Data == nil {
// Clients may express "no fixes" in a variety of ways (#64503).
if diag.Data == nil ||
len(*diag.Data) == 0 ||
len(*diag.Data) == 4 && string(*diag.Data) == "null" {
return nil
}
var fix quickFixesJSON