mirror of https://github.com/golang/go.git
internal/lsp: fix autocomplete appends on imports
Autocompleting a import without quotes appends to the completion, producing this result: `import math "math/"`. This commit changes to skip completions when typing a import without quotes, because the users can be typing the alias of the import. Fixes: golang/go#42748 Change-Id: I7050989f1f90a6720c17f71f338e50fad1f01456 GitHub-Last-Rev: e7b189a04acd8e501d6d7ac944d25de19156d0da GitHub-Pull-Request: golang/tools#263 Reviewed-on: https://go-review.googlesource.com/c/tools/+/280652 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Hyang-Ah Hana Kim <hyangah@gmail.com> Trust: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
929a8494cf
commit
b8413747bb
|
|
@ -733,6 +733,10 @@ func (c *completer) emptySwitchStmt() bool {
|
|||
// (i.e. "golang.org/x/"). The user is meant to accept completion suggestions
|
||||
// until they reach a complete import path.
|
||||
func (c *completer) populateImportCompletions(ctx context.Context, searchImport *ast.ImportSpec) error {
|
||||
if !strings.HasPrefix(searchImport.Path.Value, `"`) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// deepSearch is not valuable for import completions.
|
||||
c.deepState.enabled = false
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue