-
Notifications
You must be signed in to change notification settings - Fork 646
[improvement] Completion mess with import or already set variables #598
Comments
I was trying to repro the case when a variable and unimported package have the same name For me, the variable comes first and then the package. Can you try the code from above and see what you get? And maybe share a case where the package comes before the variable? Also can you elaborate on the below with an example?
|
Btw you should avoid to show path of packages with vendor in it ??? |
#603 will group all the packages and show them in the end after the variables/functions/others. You will get that in the next update About multiple packages having the same name, I can see how in your case it could get annoying. But, wouldn't there be a valid case where you would have 2 packages with same name but offer different things. Why shouldn't auto-complete suggest them then? About packages with "vendor" in it. If it is a vendor package in the current Go project, then the path will not have "vendor" in it. In the above case, the package is a vendor from another project. Technically, you can still import it and use it.... |
That's interesting, I tried something similar and didn't get any build errors (in the output window with buildOnSave set to true), which is why I did not remove the vendored packages from the list of importable packages. When I build my code independently outside of VS Code, I get a different error But you are right. The functions Will make that change. |
Hi @ramya-rao-a
You wont be able to build with 2 packages with the same name so importing them in the middle of your code wont be usefull. And Thanks again for your hard work on this. vscode-go rox :) |
I knew about the error on using 2 pkgs with same name. I just expected the user to add an alias to one of them 😊 What can be done in such cases is for the auto complete itself to add an alias. That should be easy. And thanks for all the feedback! That's how we can together make this a great product 😊 |
On second thoughts, I'll go with your suggestion of not showing the importable package if there is an identifier with the same name already in the Go file |
The latest update (0.6.48) has all the fixes discussed here. |
Hi, there is a new completion stuff that is pretty great.
It can let you choose a package from a list of all available package even if not imported yet.
Pretty good.
But if i have a variable with the name of a package, the completion start with unimported package when i want to use the variable.
Also if you ve already imported a package with that name some wierd stuff happen and could lead to a file with multiple import of same package but with different path.
Solution:
If a variable/package is already set in the current scope dont show any package that can be imported with the same name and also sort all the result the way that every variables already set in the scope should be first in the completion choice
The text was updated successfully, but these errors were encountered: