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

Autocomplete Improvements #990

Closed
tylerstillwater opened this issue May 11, 2017 · 4 comments
Closed

Autocomplete Improvements #990

tylerstillwater opened this issue May 11, 2017 · 4 comments

Comments

@tylerstillwater
Copy link
Contributor

I don't know how the autocomplete system works, so I'm not sure where this issue should go. I don't know how much influence this package has on the way the autocomplete does its thing.

I have two issues that are driving me insane:

  1. Snippet prefixes are always at the bottom of the autocomplete list
  2. Whole word identifiers are not selected if they contain different case letters

For example, on 1, I have a snippet defined as:

"Error Return": {
		"prefix": "ere",
		"body": "if err != nil {\n\treturn err\n}",
		"description": "Insert an error handling block to return err if not nil"
	}

When I type ere, I get a huge list of other options and have to scroll to the very bottom to find my snippet. Snippets should always be the first result if what was typed is an exact match for the prefix.

As for 2, an example would be:

type test struct {
  Field string
  fieldPrivate string
}

In this example, were I to type field, it would autocomplete and the first (and sometimes only) option would be fieldPrivate. Autocomplete should always select the case-insensitive complete word first.

Thoughts?

Thanks!

@ramya-rao-a
Copy link
Contributor

Snippet prefixes are always at the bottom of the autocomplete list

Easy fix. Set editor.snippetSuggestions to either "top" or "inline"

For the second one, are you saying that the case insensitive options are not showing up or that the case sensitive option is auto selected instead of the case insensitive one? In your example, what would be the desired items in the completion list?

how the autocomplete system works

  • We use gocode for getting the completion items
  • The snippets that you see come from either https://github.com/Microsoft/vscode-go/blob/master/snippets/go.json or user defined snippets
  • The snippets get grouped together and placed either at the top or bottom of the list if editor.snippetSuggestions is set to either "top" or "bottom". They are placed inline with the rest of the completion items if this setting is set to "inline"

@tylerstillwater
Copy link
Contributor Author

@ramya-rao-a thanks very much for that!

editor.snippetSuggestions: "top" fixes my first concern.

The second concern is that the case insensitive option, when it matches a whole word of a different case, should select that option.

A gif is worth (1000 * number of frames) words, so here's a gif:

field

Basically, when the final character in field is typed, it matches the whole-word case insensitive version of Field. My expected behavior is that it is selected, rather than fieldPrivate remaining selected.

I'm not saying this expectation is correct, of course, but it is what I have been trained to expect by other autocomplete systems.

@ramya-rao-a
Copy link
Contributor

Got it.

That is the behavior of completion item sorting/default-selection/filtering in the core VS Code and extensions don't control it

And the exact same concern was raised here: microsoft/vscode#21362
Please follow that issue.

@tylerstillwater
Copy link
Contributor Author

Excellent. Thanks for letting me know!

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