Skip to content

Commit

Permalink
internal/lsp: fix no definition when importShortcut is link
Browse files Browse the repository at this point in the history
Fixes golang/go#45987

Change-Id: I59194f41eccdd3a0df6d9a3d0cc57008c40b1450
GitHub-Last-Rev: 832d6f8
GitHub-Pull-Request: golang#317
Reviewed-on: https://go-review.googlesource.com/c/tools/+/318469
Reviewed-by: Rebecca Stambler <[email protected]>
Trust: Rebecca Stambler <[email protected]>
Trust: Suzy Mueller <[email protected]>
  • Loading branch information
zyctree authored and stamblerre committed May 10, 2021
1 parent ecb7392 commit 0185c7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/lsp/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *Server) definition(ctx context.Context, params *protocol.DefinitionPara
if err != nil {
return nil, err
}
if !snapshot.View().Options().ImportShortcut.ShowDefinition() {
if ident.IsImport() && !snapshot.View().Options().ImportShortcut.ShowDefinition() {
return nil, nil
}
var locations []protocol.Location
Expand Down
5 changes: 5 additions & 0 deletions internal/lsp/source/identifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type IdentifierInfo struct {
qf types.Qualifier
}

func (i *IdentifierInfo) IsImport() bool {
_, ok := i.Declaration.node.(*ast.ImportSpec)
return ok
}

type Declaration struct {
MappedRange []MappedRange
node ast.Node
Expand Down

0 comments on commit 0185c7e

Please sign in to comment.