Skip to content

Commit 316d2f2

Browse files
heschistamblerre
authored andcommitted
internal/lsp/source: only add names to imports when necessary
As usual, I forgot to clear out the import spec's name when it matches the import path. Change-Id: I4ddd49b70e0db95fcd30d2968b098327fac39a92 Reviewed-on: https://go-review.googlesource.com/c/tools/+/213222 Run-TryBot: Heschi Kreinick <[email protected]> Reviewed-by: Muir Manders <[email protected]> Reviewed-by: zikaeroh <[email protected]> Reviewed-by: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent acbc0e3 commit 316d2f2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

internal/lsp/source/completion.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,14 @@ func (c *completer) unimportedMembers(id *ast.Ident) error {
646646
}
647647
// We don't know what this is, so assign it the highest score.
648648
score := 0.01 * imports.MaxRelevance
649-
c.packageMembers(pkg.GetTypes(), score, &importInfo{
649+
imp := &importInfo{
650650
importPath: path,
651-
name: pkg.GetTypes().Name(),
652651
pkg: pkg,
653-
})
652+
}
653+
if imports.ImportPathToAssumedName(path) != pkg.GetTypes().Name() {
654+
imp.name = pkg.GetTypes().Name()
655+
}
656+
c.packageMembers(pkg.GetTypes(), score, imp)
654657
if len(c.items) >= unimportedTarget {
655658
return nil
656659
}

0 commit comments

Comments
 (0)