Skip to content

Commit c1d90f1

Browse files
committed
small fix
1 parent 0e0bba1 commit c1d90f1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

gopls/internal/golang/hover.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ func hover(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, pp pro
258258
// The general case: compute hover information for the object referenced by
259259
// the identifier at pos.
260260
ident, obj, selectedType := referencedObject(pkg, pgf, pos)
261+
if obj == nil || ident == nil {
262+
return protocol.Range{}, nil, nil // no object to hover
263+
}
261264

262265
if pkgName, ok := obj.(*types.PkgName); ok {
263266
rng, hoverRes, err := hoverPackageIdent(ctx, snapshot, pkg, pgf, ident, pkgName.Imported().Path())
@@ -270,10 +273,6 @@ func hover(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, pp pro
270273
return *hoverRange, hoverRes, nil // (hoverRes may be nil)
271274
}
272275

273-
if obj == nil || ident == nil {
274-
return protocol.Range{}, nil, nil // no object to hover
275-
}
276-
277276
// Unless otherwise specified, rng covers the ident being hovered.
278277
if hoverRange == nil {
279278
rng, err := pgf.NodeRange(ident)

0 commit comments

Comments
 (0)