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

Autocompletion order is a bit meh #680

Closed
atombender opened this issue Dec 5, 2016 · 14 comments
Closed

Autocompletion order is a bit meh #680

atombender opened this issue Dec 5, 2016 · 14 comments
Assignees

Comments

@atombender
Copy link

Here's an example where I have to type way more than I expect.

screen shot 2016-12-04 at 22 21 37

screen shot 2016-12-04 at 22 21 51

screen shot 2016-12-04 at 22 22 04

All choices are very bad; I have to type "constr" to match "constraints", when I should only need to type "c" to get it as the first hit.

In short, the autocompletion should emphasize near things (local variables/arguments, nearby functions, and so on), over farther-away things (like imports and snippets). I think character distance is as important a clue as lexical-scope distance.

I've also noticed that the autocompletion is peculiarly picky about case. Notice how "Constraint" (capitalized) is not among any of the hits. It's nice that case is used as a hint, but I really expect "Constraint" to be the second suggestion.

@ramya-rao-a
Copy link
Contributor

The autocomplete for unimported packages that was introduced a few updates ago have 2 features

  • Add all the importable packages in the completion items
  • A dot after an unimported packagename would give you auto-complete options for members of that package.

Its the first feature above that adds a lot of noise to completion items in a lot of cases (yours included).
One improvement that was done was to sort the completion items such that the completion items from the first feature above appear in the end after the "real" items like variables/arguments/functions

But the noise continues as in your case.

The sorting of completion items is controlled by the extension, but the selected item is controlled by VS Code based on algorithms that work on just the text you type and the text in the completion item. As far as I know, the extension has no way of telling VS Code of ranking for the completion items.

Long story short, do you believe the first feature above is actually useful? If not I'd suggest setting go.autocompleteUnimportedPackages to false. This will disable the first feature above, but will keep the second one intact.

@atombender
Copy link
Author

I understand. It's weird that VSCode doesn't allow an extension to order the matches. Surely VSCode doesn't know what the items mean, so it can't order them appropriately.

This issue also affects "Go to Symbol" (@) — imports come before declarations/definitions — although that's evidently because it lists stuff in declaration order. But if start typing stuff to fuzzy match, there's pretty much no reason imports should ever come above definitions. Deserves separate issue, perhaps?

@atombender
Copy link
Author

Forgot to say: Turn off go.autocompleteUnimportedPackages helps a lot, thanks.

@ramya-rao-a
Copy link
Contributor

Regarding the "Go to Symbol", I always thought it is not of much use to even have the import statements show up in the first place. Not just for Go, but for other languages like typescript as well.

I wonder if the autocompleteUnimportedPackagea setting should be set to false by default. If there is more feedback, we might just do tgat

@atombender
Copy link
Author

Yep to both. Imports in "Go to Symbol" do seem pretty useless.

@ramya-rao-a
Copy link
Contributor

The update previous to the current update of the Go extension has go.autocompleteUnimportedPackages set to false by default.

For the "Go to Symbol" issue, I was thinking of adding a setting go.ignoreImports. If true then the imports will be ignored in the "Go to Symbol" output.

@ramya-rao-a ramya-rao-a self-assigned this Feb 3, 2017
@atombender
Copy link
Author

I recommend reversing it: go.autocomplete.includeImports or whatever, set to false by default. If people like the old behaviour, they can turn it on.

@ramya-rao-a
Copy link
Contributor

@atombender I think we are talking about different things.

go.autocompleteUnimportedPackages that controls the importable packages showing up in suggestion list is already set to false by default as of 2 updates ago.

go.ignoreImports would be a new setting (not yet coded) that would control imports showing up in Go to symbol/File Outline/@ feature

@atombender
Copy link
Author

I was actually talking about the same thing, ignore the reference to autocompletion. Surely go.ignoreImports is too vague a name for that setting, though.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Feb 4, 2017

That's right, naming needs work. I initially thought of go.ignoreImportsInFileOutline (I know, I am bad at naming), but I like your approach of go.featurename.settingname.
So go.symbolSearch.ignoreImports is indeed better.

@ramya-rao-a
Copy link
Contributor

The setting is called "go.gotoSymbol.includeImports" and is false by default.
Therefore, the default behavior will be excluding the import statements.
PR is merged.
The change will be out in the next update

@atombender
Copy link
Author

Superb, thank you.

@ramya-rao-a
Copy link
Contributor

This feature (ignoring import statements in the Go to Symbol feature) is now available in the latest update (0.6.54) to the Go extension.

@atombender
Copy link
Author

Yay!

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 23, 2018
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

2 participants