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: import statement added before package declaration when preceded by comment #33721

Closed
suzmue opened this issue Aug 19, 2019 · 3 comments
Labels
Milestone

Comments

@suzmue
Copy link
Contributor

@suzmue suzmue commented Aug 19, 2019

Running gopls version:
golang.org/x/tools/gopls v0.1.3
golang.org/x/tools/gopls@(devel)

settings:
"gopls": {
"useDeepCompletion": true,
"wantUnimportedCompletions": true,
},

What did you do?

Selected a completion of an unimported standard library package.

// Hello
package main

func _() {
	<> // trigger completion and select unimported package fmt
}

What did you expect to see?

The import being added after the package statement.

// Hello
package main

import "fmt"

func _() {
	fmt
}

What did you see instead?

The import was added before the package statement.

// Hello

import "fmt"

package main

func _() {
	fmt
}

@gopherbot gopherbot added this to the Unreleased milestone Aug 19, 2019
@gopherbot gopherbot added the gopls label Aug 19, 2019
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 19, 2019

Thank you for filing a gopls issue! Please take a look at the Troubleshooting section of the gopls Wiki page, and make sure that you have provided all of the relevant information here.

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 19, 2019

Change https://golang.org/cl/190800 mentions this issue: internal/lsp: test adding imports for package statements with comments

@suzmue

This comment has been minimized.

Copy link
Contributor Author

@suzmue suzmue commented Aug 19, 2019

@suzmue suzmue closed this Aug 19, 2019
gopherbot pushed a commit to golang/tools that referenced this issue Aug 19, 2019
Test that having a comment at the start of a file allows imports
to be added correctly.

Updates golang/go#33721

Change-Id: Id1673c2509537413710b73261ad2a59afe06b93f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/190800
Run-TryBot: Suzy Mueller <suzmue@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.