Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: suppress signature help inside string literal #43397

zmb3 opened this issue Dec 27, 2020 · 2 comments

x/tools/gopls: suppress signature help inside string literal #43397

zmb3 opened this issue Dec 27, 2020 · 2 comments


Copy link

@zmb3 zmb3 commented Dec 27, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • 1.15.6
  • Run gopls -v version to get version of Gopls if you are using the language server.
    • Built from source @ e7a54586433042185aa9b6a4603e98e676d0487c
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.20.0

Share the Go related settings you have added/edited

"go.useLanguageServer": true,
  "go.languageServerExperimentalFeatures": {
    "diagnostics": true,
    "documentLink": false
  "go.delveConfig": {
    "dlvLoadConfig": {
      "maxStringLen": 1024,
    "apiVersion": 2,
  "[go]": {
    "editor.snippetSuggestions": "none",
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": true
  "gopls": {
    "usePlaceholders": true, // add parameter placeholders when completing a function
    "staticcheck": false, // uses too much memory right now
    "gofumpt": true

Describe the bug

I am seeing the signature help popup when I press the , key inside a string literal. This is distracting, as I'm not needing signature help and the popup is obstructing the code I need to see while completing a method call.

In this case, the signature help is constantly obstructing my view of the code when writing SQL inside a string literal. It occurs both inside " and backtick terminated strings, and seems to occur both when gopls.usePlaceholders is true and false.

I would expect that just like autocomplete, we suppress signature help inside the string literal, and that I don't see the signature help window again until I complete the string literal and then press ,.

Steps to reproduce the behavior:

  1. Open editor and start writing out a method call where one argument is a string.
  2. When you get to typing the first ( character observe the signature help dialog present itself. This is normal and expected as it is now time to fill in the arguments.
  3. Dismiss the signature help window by pressing escape.
  4. Start typing a string literal "...
  5. Enter a , before closing the string with ".
  6. Observe the signature help window come up again when the , is entered. This is unexpected.

Screenshots or recordings


@stamblerre stamblerre transferred this issue from golang/vscode-go Dec 28, 2020
@stamblerre stamblerre changed the title Suppress signature help inside string literal x/tools/gopls: suppress signature help inside string literal Dec 28, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 28, 2020
@stamblerre stamblerre added FeatureRequest and removed Tools gopls labels Dec 28, 2020
Copy link
Contributor Author

@zmb3 zmb3 commented Dec 31, 2020

Happy to submit a CL for this with some guidance - the gopls codebase has changed a bit from when I last looked.

Do we really think this is a gopls issue and not an editor issue though? gopls is returning the correct signature help when asked. I would think it should be the editor's responsibility to ensure a nice user experience and not ask gopls for help when it is not desired.

Copy link

@stamblerre stamblerre commented Jan 5, 2021

The issue is that the editor doesn't parse the file when gopls is running, so it's not aware that the cursor is in a string literal. I think it would probably be easiest to put that logic in gopls, but this does pose the question of if some users might want signature help even in this case. For your reference, the bulk of the signature help logic is here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.