-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Quoted string always presents irrelevant suggestion list #367
Comments
Gocode just tries to find the best completion results it can when you ask it to. If editor triggers completion at weird location it's a problem of an editor. Gocode has no semantics of "valid completion point". |
I understand your point. However, I am surprised at the wrong suggestions, but after reading point no. 4 in #307 it sounds as if gocode is not looking at the surrounding context (enough). I haven't internalized the details of gocode yet enough to make the fix but it looks like this case could be handled near here: https://github.com/nsf/gocode/blob/master/cursorcontext.go#L285 If you think that sounds right I'd be happy to work on this small fix, but if this is the wrong location to handle this case I'd love a pointer to elsewhere. |
Well in both of your examples it shows package-level autocompletion list, which means no context is considered. Gocode recognizes only few contexts: 1. when something before the cursor looks like a dot expression (e.g. Gocode doesn't recognize fancier contexts like function arguments and if statements and other things where you might do some better hinting. |
Oh and what kind of completion do you expect after a string literal? |
I would expect an empty list (i.e., no suggestions) after completion of a string literal. Perhaps this can be solved in the editor as you suggest. I have commented on a relevant issue there. Thanks for your help. |
Yeah, gocode never returns an empty result. At least it shouldn't, maybe there are cases with incorrect syntax that you can make it do so, but the intentional logic is to try to narrow down the choice using some context, if no context is found, just return everything that is visible from cursor position. However if editor triggers autocompletion automatically in such places, I believe it can be prevented. Personally I don't like automatic autocompletions at all, I use a key to trigger it, but most editors have some sort of a prefix regexp which allows and disallows automatic triggering. No idea about visual studio code though, I don't use it for Go. |
Hi, first-time gocode user (using with VSC, inspecting output with debugging console). First, gocode is tremendous -- thank you!
I don't know any other way to to describe this behavior succinctly other than: "Every time I close the quotes on a string, I am presented with a list of irrelevant suggestions. This is extremely irritating because if I for example am defining a string:
By the time I close the string "A String", gocode suggests a long list of autocompletion, so when I hit enter to go to the next line, I instead get inserted the first suggestion (in this case
func append([]type, ...type) []type
)Help!
Debugging output:
Example 1:
Example 2 (same behavior, different context):
The text was updated successfully, but these errors were encountered: