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
Assignees
Labels
Milestone

Comments

@zeebo
Copy link
Contributor

@zeebo 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
@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik 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

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 12, 2019

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

@heschik

This comment has been minimized.

Copy link
Contributor

@heschik heschik 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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.