-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: support InsertReplaceEdit completion items #61215
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
Comments
Gopls does not yet support |
We should definitely support this; it's a pain point I run into frequently. Transferring. |
Change https://go.dev/cl/585275 mentions this issue: |
Change https://go.dev/cl/587135 mentions this issue: |
InsertReplaceEdit is used instead of TextEdit in CompletionItem in editors that support it. These two types are alike in appearance but can be differentiated by the presence or absence of certain properties. UnmarshalJSON of the sum type tries to unmarshal as TextEdit only if unmarshal as InsertReplaceEdit fails. Due to this similarity, unmarshal with the different type never fails. Add a custom JSON unmarshaller for InsertReplaceEdit, so it fails when the required fields are missing. That makes Or_CompletionItem_textEdit decode TextEdit type correctly. For golang/go#40871 For golang/go#61215 Change-Id: I62471fa973fa376cad5eb3934522ff21c14e3647 Reviewed-on: https://go-review.googlesource.com/c/tools/+/587135 Reviewed-by: Peter Weinberger <pjw@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.gotests: D:\Projects\Code\Go\bin\gotests.exe (version: v1.6.0 built with go: go1.20.1)
gomodifytags: D:\Projects\Code\Go\bin\gomodifytags.exe (version: v1.16.0 built with go: go1.20.1)
impl: D:\Projects\Code\Go\bin\impl.exe (version: v1.1.0 built with go: go1.20.1)
goplay: D:\Projects\Code\Go\bin\goplay.exe (version: v1.0.0 built with go: go1.20.1)
dlv: D:\Projects\Code\Go\bin\dlv.exe (version: v1.20.1 built with go: go1.20.1)
staticcheck: D:\Projects\Code\Go\bin\staticcheck.exe (version: v0.4.2 built with go: go1.20.1)
gopls: D:\Projects\Code\Go\bin\gopls.exe (version: v0.12.2 built with go: go1.20.1)
Share the Go related settings you have added/edited
Describe the bug
VsCode setting
"editor.suggest.insertMode": "insert"
has no effect in Go code.Steps to reproduce the behavior:
fmt.Println(Sword{Blade: Blade{Length: 0.8, Sharpness: 0.7}})
, place cursor in front of the first occurrence ofBlade
.Hi
to trigger autocompletion.Hilt
from the suggestions.Blade
is replaced byHilt
yieldingfmt.Println(Sword{Hilt: Blade{Length: 0.8, Sharpness: 0.7}})
instead offmt.Println(Sword{HiltBlade: Blade{Length: 0.8, Sharpness: 0.7}})
.The text was updated successfully, but these errors were encountered: