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

Closed
zmb3 opened this issue Dec 27, 2020 · 5 comments
Closed

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

zmb3 opened this issue Dec 27, 2020 · 5 comments
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@zmb3
Copy link
Contributor

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.
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
1.53.0-insider
4a875e23d20b64504a818834f3fa4c40adb8d480
x64
  • 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

image

@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 Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 28, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 28, 2020
@stamblerre stamblerre added FeatureRequest and removed Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Dec 28, 2020
@stamblerre stamblerre added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. FeatureRequest help wanted labels Dec 28, 2020
@zmb3
Copy link
Contributor Author

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.

@stamblerre
Copy link
Contributor

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: https://github.com/golang/tools/blob/c658f99295e8a2631f08de8aa6c76a8e14ae0f9a/internal/lsp/source/signature_help.go#L19.

@KarthikNayak
Copy link
Contributor

Can I pick this up? I'm going under the impression that this is a bug and that nobody wants this.
@zmb3 @stamblerre

KarthikNayak added a commit to KarthikNayak/tools that referenced this issue Jul 25, 2021
Currently the `SignatureHelp` function provides signature help even when the
requested range lies within a string literal. Let's suppress this behavior and
return an error when someone requests signature help from within a string
literal.

Fixes golang/go#43397

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
@gopherbot
Copy link

Change https://golang.org/cl/337170 mentions this issue: internal/lsp: skip signature help within a string literal

@zmb3
Copy link
Contributor Author

zmb3 commented Jul 26, 2021

Thanks, @KarthikNayak!!

@golang golang locked and limited conversation to collaborators Jul 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. help wanted Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants