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
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@suzmue
Copy link
Contributor

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 Issues related to the Go language server, gopls. label Aug 19, 2019
@gopherbot
Copy link

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
Copy link

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

@suzmue
Copy link
Contributor Author

suzmue commented Aug 19, 2019

Fixed by http://golang.org/cl/190598

@suzmue suzmue closed this as completed 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>
@golang golang locked and limited conversation to collaborators Aug 18, 2020
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.
Projects
None yet
Development

No branches or pull requests

2 participants