Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Go: Autocomplete Unimported Packages works on variable or package symbols #2469

Closed
szyhf opened this issue Apr 25, 2019 · 21 comments
Closed

Comments

@szyhf
Copy link

szyhf commented Apr 25, 2019

My go extension suddenly doesn't works well on "Go: Autocomplete Unimported Packages".

If I set the setting of "Go: Autocomplete Unimported Packages" to true, it works well if I first type package name on blank line as I wish, for example:

error2

But if I already import the package or using an existing variable, it also show the suggest of package, mixed with the 'Member variables' for example:

err

And what I used to and expect to see is:

11

I don't know why and I didn't change any setting before.

Really thanks for help.


go env

go version go1.12.4 darwin/amd64
macOS Mojave 10.14.4
@szyhf
Copy link
Author

szyhf commented Apr 25, 2019

I‘ve already tried reinstall all go tools and kill old gocode process.

@nanght
Copy link

nanght commented Apr 25, 2019

I have the same issues, vs code not auto import.

@szyhf
Copy link
Author

szyhf commented Apr 25, 2019

I have the same issues, vs code not auto import.

No, my problem is auto import package while I type '.' after a variable, in this case I just want to see the member of the variable Orz

@nanght
Copy link

nanght commented Apr 25, 2019

i just fixed:

  1. stop VS code
  2. delete file: %UserProfile%\AppData\Roaming\Code\User\settings.json
  3. start again

@rokf
Copy link

rokf commented Apr 25, 2019

Deleting "go.useLanguageServer": true from the settings should work.

@Hawken94
Copy link

I have the same issues, vs code not auto import.

No, my problem is auto import package while I type '.' after a variable, in this case I just want to see the member of the variable Orz

I also meet the issues, vs code will show all the packages from gopath rather than the member of the variable. This happens suddenly. I remember it worked well a few days ago.

go version go1.12.4 darwin/amd64
macOS Mojave 10.13.6
vscode: 1.33.1
vscode-go:0.10.1

image

vs code setting:

 {
    "go.autocompleteUnimportedPackages": true,
    "go.useCodeSnippetsOnFunctionSuggest": true,
    "go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
    "go.lintTool": "golint",
    "go.lintOnSave": "workspace"
}

@szyhf
Copy link
Author

szyhf commented Apr 25, 2019

Deleting "go.useLanguageServer": true from the settings should work.

I didn't use "go.useLanguageServer"

@jellevandenhooff
Copy link

jellevandenhooff commented Apr 25, 2019

This happens to me both go.useLanguageServer and without. It started happening recently. It make autocompleteUnimportedPackages impossible to use. Reverting to 0.9.2 makes the problem disappear.

@szyhf
Copy link
Author

szyhf commented Apr 26, 2019

This happens to me both go.useLanguageServer and without. It started happening recently. It make autocompleteUnimportedPackages impossible to use. Reverting to 0.9.2 makes the problem disappear.

Thanks a lot, I'll revert it~

@malexdev
Copy link

I'm having this same issue. Something in v0.10 broke.

Autocompletion seems to suggest the correct symbols, but it also suggests a bunch of other unimported packages, and the cursor for some reason suggests the package I'm trying to complete members for.

Example:
example

That same snippet, with the autocomplete box scrolled up:
example-scrolled-up

I have tried completely uninstalling Go, VS Code, the VS Code Go extension, and removing every single customization setting from VS Code. Nothing seems to help.

This is using the latest versions of the tools VS Code auto installs as of today (2019-04-26), since I completely removed and reinstalled everything. I'm also not using modules yet.

As mentioned earlier this thread, reverting to 0.9.2 fixes the issue. I'm just adding this for additional information if it is helpful.

Sample code:

package password

import (
	"crypto/rand"
)

func randomInt() (int, error) {
	var b []byte
	rand. // autocompleting here fails to sort properly and suggests a lot of unimported packages
}

Go settings:

{
    "go.autocompleteUnimportedPackages": false,
    "go.useCodeSnippetsOnFunctionSuggest": false,
    "go.useCodeSnippetsOnFunctionSuggestWithoutType": false,
}

Steps to Reproduce:

  1. Create a new package.
  2. Import anything.
  3. Attempt to use autocomplete on the imported package.

@jellevandenhooff
Copy link

jellevandenhooff commented Apr 27, 2019

FYI @ramya-rao-a -- do you have any idea which 0.10 changes might be related? And thanks for the wonderful plugin!

@magnuswahlstrand
Copy link

I have the same problem:

  • VSCode Version: 1.33.1, 51b0b28134d51361cf996d2f0a1c698247aeabd8, x64
  • OS Version: macOS Sierra, 10.12.6

I backed to 0.9.2, and it solved. Thanks for the suggestion! Coding is impossible with 0.10.

@ramya-rao-a
Copy link
Contributor

Hello all,

Thanks for reporting the issue. This is definitely a regression i.e. this wasnt a problem in the previous version of this extension (0.9.2).

I have pushed a fix for this. Please try the latest beta version of this extension which has the fix for this and let me know how it goes.

If a couple of you can confirm the fix, I will release an update soon

@szyhf
Copy link
Author

szyhf commented Apr 30, 2019

@ramya-rao-a Thanks a lot !!

@malexdev
Copy link

malexdev commented Apr 30, 2019

@ramya-rao-a The beta version fixes the issue for me. Thanks for the quick response!

It also broke my tab size settings - I went from 2 space sized tabs to 8 space sized tabs (ignoring my VSCode settings, which were still set to 2 spaces). But I imagine that's just something to do with the fact that it's a beta version.

@ramya-rao-a
Copy link
Contributor

Apologies on the tab size change
It should be back to normal in the beta update(0.10.2-beta.2) that I just released

@malexdev
Copy link

@ramya-rao-a No worries here. That fixed everything perfectly. Thanks so much!

@ramya-rao-a
Copy link
Contributor

The fix to this has been released in the latest update (0.10.2)

@keyvchan
Copy link

keyvchan commented May 1, 2019

So the GO: Autocomplete Unimported Packages option isn't work now? When I try to use this feature and this option is checked, it seem nothing happened and no autocompletion . It's a problem since I using gopls and seem like no one mentioned before.
image

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented May 1, 2019

@fintanchen Is your project under your GOPATH or are you using Go modules?

If you are using Go modules, then yes this feature doesnt work in such cases and I have logged #2484 to track next steps.

If you are not using Go modules, then this feature will work regardless of whether you use gopls or not

@keyvchan
Copy link

keyvchan commented May 2, 2019

@ramya-rao-a Thans for your work. I am using Go modules. I will check #2484.

@microsoft microsoft locked as resolved and limited conversation to collaborators May 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants