Skip to content

x/tools/gopls: accepting autocomplete suggestion within invalid code results in unwanted code deletion #77481

Description

@igadmg

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

  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.25.6 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.21.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.109.0 bdd88df003631aaa0bcbe057cb0a940b80a476fa x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.52.2

Describe the bug

When editing not correct go code, if autocompleted is initiated and accepted all incorrect code is deleted.
Here is example of code I edit

`
package editor

type Theme struct {
MainTextColor colore

MenuHeight      float32 = 20
ToolbarHeight   float32 = MenuHeight
TabButtonWidth  float32 = 60
TabButtonHeight float32 = 30

}
`

I am editing line MainTextColor colore, autocomplete emerges and propose me to autocomplete colore to colorex. If I accept, half of code is deleted and I get this

`
package editor

import "github.com/igadmg/goex/image/colorex"

type Theme struct {
MainTextColor colore
colorex
MenuHeight float32
}
`

Screenshots or recordings

Here is a vide recording of that https://imgur.com/a/YeEU0Xl

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.gopls/completionIssues related to auto-completion in gopls.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions