From 8b0f8a79195ea7ee32235df9f70e8ed3a8c6ac67 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Sun, 10 May 2020 01:49:52 -0400 Subject: [PATCH] internal/lsp/source: handle nil pointer in package name hover Updates golang/go#38977. Change-Id: I8cbf0b058d77e749285cfe41b4b49de3764be861 Reviewed-on: https://go-review.googlesource.com/c/tools/+/233177 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Heschi Kreinick --- internal/lsp/source/identifier.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/lsp/source/identifier.go b/internal/lsp/source/identifier.go index 2c2266c9fb..85ca19fb1e 100644 --- a/internal/lsp/source/identifier.go +++ b/internal/lsp/source/identifier.go @@ -103,6 +103,10 @@ func findIdentifier(ctx context.Context, s Snapshot, pkg Package, file *ast.File declAST = f } } + // If there's no package documentation, just use current file. + if declAST == nil { + declAST = file + } declRng, err := posToMappedRange(view, pkg, declAST.Name.Pos(), declAST.Name.End()) if err != nil { return nil, err