Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: inconsistent placement of new import with local #35519

Closed
zeebo opened this issue Nov 11, 2019 · 3 comments
Closed

x/tools/gopls: inconsistent placement of new import with local #35519

zeebo opened this issue Nov 11, 2019 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zeebo
Copy link
Contributor

zeebo commented Nov 11, 2019

Consider a module bug with package bug/bar that exports identifier X. gopls is configured to have the local option equal to "bug/". In the package bug, we have the source

package bug

import (
	"fmt"

	"golang.org/x/tools/blog"
)

var _ = fmt.Println

type _ = blog.Config

var _ = bar.X // user has just finished typing this

Issuing an Organize Imports action respects the local option and leaves the import block as

import (
	"fmt"

	"bug/bar"

	"golang.org/x/tools/blog"
)

whereas if the import for "bug/bar" is added through code complection, the import block will be

import (
	"fmt"
	"bug/bar"

	"golang.org/x/tools/blog"
)

which does not respect the local option.

@gopherbot gopherbot added this to the Unreleased milestone Nov 11, 2019
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Nov 11, 2019
@heschi
Copy link
Contributor

heschi commented Nov 12, 2019

source.addNamedImport almost certainly needs to read the "local" configuration and does not. Not sure why we need this vs. sharing code with source.computeImportEdits.

@gopherbot
Copy link

Change https://golang.org/cl/206881 mentions this issue: internal/lsp/source: unify import adding code

@heschi
Copy link
Contributor

heschi commented Nov 12, 2019

Er...I just realized I didn't actually test this exact case. But I'm pretty sure it's fixed. If not please comment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants