microsoft/vscode-go

Background of covered and not covered code cannot be removed after running package test

xhit opened this issue ยท 9 comments

xhit commented

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

  • Run go version to get version of Go
    • go version go1.14.3 windows/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
1.45.1
5763d909d5f12fe19f215cbfdd29a91c0fa9208a
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.14.2
  • Run go env to get the go development environment details
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\sdelacruz\AppData\Local\go-build
set GOENV=C:\Users\sdelacruz\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\sdelacruz\Documents\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\sdelacruz\sdk\go1.14.3
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\sdelacruz\sdk\go1.14.3\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\sdelacruz\Documents\go\src\sdi\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\SDELAC~1\AppData\Local\Temp\go-build095799566=/tmp/go-build -gno-record-gcc-switches

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"] or gopls prefixes.

{
    "go.goroot": "C:/Users/sdelacruz/sdk/go1.14.3"
}

Describe the bug

Before Go extension 0.14.2, when I executed the run package test the covered and not covered code showed in green and red background can be restored to code without the background only editing a file. Now is not possible. I need to restart vscode to remove that background.

Steps to reproduce the behavior:

  1. Execute run package test
  2. Edit a go file in the package with covered or not covered code
xhit commented

I notice that issue #2551 is related and the PR #2853 is the root cause, so:

  • There are options to returns back to previously behavior?
  • Why maintain this background of covered code always even when new code is added and file edited?

@xhit does the coverage info still remain if the edited file is saved?
I believe the issue #2551 is a feature request to preserve the coverage info while typing because otherwise, it is difficult to fix code based on the coverage feedback.

xhit commented

does the coverage info still remain if the edited file is saved?

Yes.

Thanks. I could reproduce this as well.
@ramya-rao-a @kegsay Is this intended behavior?

I would strongly support reverting this change. I thought my IDE was broken because changing code and saving would no longer remove the coverage highlighting, as it has for literally years prior.

If not, please give us a toggle to support the original behavior. I know I can bring up the menu and toggle test coverage (or set a keybinding, etc, etc), but that's a slew of new steps that weren't needed before.

I had the same experience, @blocknonip. I thought I was going crazy for about an hour - went through restarting/reinstalling everything multiple times, modifying all the coverage-related settings...

I understand the motivation for this, and can see how maintaining the highlighting during typing is potentially helpful. But from my reading of the PR, I also assumed that the coverage info would disappear if the file was saved. Instead, for me, new text is highlighted in a grayer shade of green, and I can only turn it off with the menu > toggle.

One of the conditionals on https://github.com/microsoft/vscode-go/pull/2853/files#diff-44e85398a1742b4d78705053c4a98671R300 must be failing - there was a long period between me making that PR and asserting its behaviour and it ended up getting merged in, so it's possible something has changed in the intervening months which breaks the PR.

@kegsay thanks for the pointer. I don't know why but I observed isDirty is never true when the callback is invoked. Can you please take a look at the linked PR?

@ramya-rao-a I sent my PR for the fix in golang/vscode-go. How do you want to handle PRs for minor bug fixes like this during the repo migration?

Sorry about this folks and thanks for the pointer to the PR @hyangah

I consider this more than a minor bug, so I went ahead with the fix and have released an update (version 0.14.3). The code coverage should be cleared on file save now.

Thanks for reporting @xhit!