/ go Public
x/tools/gopls: filter useless completion candidates #37718
Issues related to the Go language server, gopls.
Feedback is required from experts, contributors, and/or the community before a change can be made.
This label describes issues relating to any tools in the x/tools repository.
I think we are at a point where we can consider filtering out completion candidates that are probably useless. We still have to be careful because it is normal for users to sometimes compose Go code "out of order", or use completion on an empty line to explore what is available, or otherwise try to complete something that isn't "quite right" yet. Also keep in mind that gopls having no expected type doesn't necessarily mean there is no expected type - there could be a syntax error we don't work around yet.
Here are some concrete situations to consider:
If we have an expected type, don't offer func candidates that return no values. This one seems pretty low risk. There are still edge case false negatives such as a user wanting to complete to a void function with the intention of then going and adding a return value.
If we have an expected type and it isn't bool, omit otherwise non-matching type name candidates that have no methods. This seems medium risk. For example:
Please comment with other low risk opportunities to omit candidates.
The text was updated successfully, but these errors were encountered: