1
0
mirror of https://github.com/golang/go synced 2024-11-18 21:05:02 -07:00

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 <heschi@google.com>
Reviewed-by: Muir Manders <muir@mnd.rs>
Reviewed-by: zikaeroh <zikaeroh@gmail.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Heschi Kreinick 2020-01-03 18:46:37 -05:00 committed by Rebecca Stambler
parent acbc0e3ba1
commit 316d2f2484

View File

@ -646,11 +646,14 @@ func (c *completer) unimportedMembers(id *ast.Ident) error {
} }
// We don't know what this is, so assign it the highest score. // We don't know what this is, so assign it the highest score.
score := 0.01 * imports.MaxRelevance score := 0.01 * imports.MaxRelevance
c.packageMembers(pkg.GetTypes(), score, &importInfo{ imp := &importInfo{
importPath: path, importPath: path,
name: pkg.GetTypes().Name(),
pkg: pkg, pkg: pkg,
}) }
if imports.ImportPathToAssumedName(path) != pkg.GetTypes().Name() {
imp.name = pkg.GetTypes().Name()
}
c.packageMembers(pkg.GetTypes(), score, imp)
if len(c.items) >= unimportedTarget { if len(c.items) >= unimportedTarget {
return nil return nil
} }