microsoft / vscode-go

An extension for VS Code which provides support for the Go language. We have moved to https://github.com/golang/vscode-go
Other
5.93k stars 648 forks source link

Breakpoints being deleted/moved on file save #3180

Closed KyleKotowick closed 4 years ago

KyleKotowick commented 4 years ago

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

go1.14 windows/amd64

1.44.0 2aae1f26c72891c399f860409176fe435a154b13 x64

0.13.1

windows amd64

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file. Share all the settings with the go. or ["go"] prefixes.

{
    "go.useLanguageServer": true,
    "go.languageServerExperimentalFeatures": {
        "format": true,
        "diagnostics": true,
        "documentLink": true
    },
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },
        // Optional: Disable snippets, as they conflict with completion ranking.
        "editor.snippetSuggestions": "none",
    },
    "[go.mod]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        },
    }
}

Describe the bug

When saving a .go file, all breakpoints are removed from the file.

Steps to reproduce the behavior:

  1. Edit a .go file
  2. Set breakpoints on any two lines other than the first line
  3. Save the file
  4. Notice that the breakpoints you set have disappeared, and there is now a single breakpoint on the first line.

Screenshots or recordings

Breakpoint

KyleKotowick commented 4 years ago

After some further testing, I've found that if I set:

"[go]": {
        "editor.formatOnSave": false,
}

Instead of true, this issue does not occur.

hyangah commented 4 years ago

Strangely I couldn't reproduce the problem. I copied the settings. Checked vscode/extension/go versions. The only difference I see is I am using mac, not windows. Puzzled.

dbg

hyangah commented 4 years ago

@kkotowick can you also share the list of active extensions?

KyleKotowick commented 4 years ago

Enabled extensions:

Docker 1.0.0 (ms-azuretools.vscode-docker) Go 0.14.1 (ms-vscode.go) PowerShell 2020.4.0 (ms-vscode.powershell) Python 2020.3.71659 (ms-python.python) Remote - WSL 0.44.2 (ms-vscode-remote.remote-wsl) Terraform 1.4.0 (mauve.terraform) XML Tools 2.5.0 (dotjoshjohnson.xml)

lggomezml commented 4 years ago

I´m now sure this is related to the debug feature, as it seems to be something related to the workbench events and actions rather than anything from the debug adapter side (AFAIK we can't even control that state programatically from that process, only via responses once a debug session is active)

edit: these are just my two cents on the debug label

hyangah commented 4 years ago

@lggomezml That sounds like this is an issue to be reported to upstream (microsoft/vscode).

@kkotowick I cannot even reproduce this on my mac to file an issue myself. It may be possible that this is isolated to the windows UI. Can you please file an issue in the upstream repo? Thanks.

dtsao commented 4 years ago

Same issue here. $ go version go version go1.13.7 windows/amd64 $ code -v 1.45.0 d69a79b73808559a91206d73d7717ff5f798f23c x64 go extension: 0.14.2 $ go env GOOS GOARCH windows amd64

@kkotowick's work around works for me https://github.com/microsoft/vscode-go/issues/3180#issuecomment-614238283

stamblerre commented 4 years ago

I've just tried to reproduce this on my Windows machine, and I wasn't able to, even when the file has to be formatted and changed. It does sound like an upstream VS Code issue, so I'm going to go ahead and close this and suggest filing an issue in https://github.com/microsoft/vscode.

It might also be useful to check the gopls version (gopls version) to confirm that it is at the latest (gopls/v0.4.1), because there were some formatting bugs with gopls in earlier versions.