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: support InsertReplaceEdit completion items #61215

Open
Zyl9393 opened this issue Jun 20, 2023 · 2 comments
Open

x/tools/gopls: support InsertReplaceEdit completion items #61215

Zyl9393 opened this issue Jun 20, 2023 · 2 comments
Labels
gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@Zyl9393
Copy link

Zyl9393 commented Jun 20, 2023

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

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.20.1 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • v0.12.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.79.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.39.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > 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

    "go.useLanguageServer": true,
    "go.lintOnSave": "off",

Describe the bug

VsCode setting "editor.suggest.insertMode": "insert" has no effect in Go code.

Steps to reproduce the behavior:

  1. Write some code:
package main

import "fmt"

type Sword struct {
	Blade
	Hilt
}

type Blade struct {
	Length    float64
	Sharpness float64
}

type Hilt struct {
	Girth float64
}

func main() {
	fmt.Println(Sword{Blade: Blade{Length: 0.8, Sharpness: 0.7}})
}
  1. On the line fmt.Println(Sword{Blade: Blade{Length: 0.8, Sharpness: 0.7}}), place cursor in front of the first occurrence of Blade.
  2. Type Hi to trigger autocompletion.
  3. Choose Hilt from the suggestions.
  4. Blade is replaced by Hilt yielding fmt.Println(Sword{Hilt: Blade{Length: 0.8, Sharpness: 0.7}}) instead of fmt.Println(Sword{HiltBlade: Blade{Length: 0.8, Sharpness: 0.7}}).
@hyangah
Copy link
Contributor

hyangah commented Jun 22, 2023

Gopls does not yet support InsertReplaceEdit feature (available from LSP3.16).
@findleyr Do you want to move this to the gopls issue tracker as a feature request?

@findleyr findleyr changed the title VsCode setting "editor.suggest.insertMode": "insert" has no effect x/tools/gopls: support InsertReplaceEdit completion items Jul 6, 2023
@findleyr
Copy link
Contributor

findleyr commented Jul 6, 2023

We should definitely support this; it's a pain point I run into frequently.

Transferring.

@findleyr findleyr transferred this issue from golang/vscode-go Jul 6, 2023
@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 Jul 6, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jul 6, 2023
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.13.0 Jul 6, 2023
@findleyr findleyr added the gopls/completion Issues related to auto-completion in gopls. label Jul 6, 2023
@findleyr findleyr modified the milestones: gopls/v0.14.0, gopls/v0.15.0 Sep 27, 2023
@findleyr findleyr modified the milestones: gopls/v0.15.0, gopls/v0.16.0 Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants