Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Test coverage color refresh issue in split view #2045

Closed
SteelPhase opened this issue Oct 24, 2018 · 3 comments
Closed

Test coverage color refresh issue in split view #2045

SteelPhase opened this issue Oct 24, 2018 · 3 comments

Comments

@SteelPhase
Copy link
Contributor

SteelPhase commented Oct 24, 2018

macOS 10.13.6, and Windows 10 Version 1809 (OS Build 17763.55)
vscode 1.28.2
go plugin 0.6.93
golang v1.11.1

Tested with only the go plugin enabled

While writing unit tests for a go file, I had vscode split horizontally. The left panel being my actual code lets say thing.go. The right panel was thing_test.go. After code coverage highlighting has been toggled, any time you focus back on the thing.go panel, the code coverage highlighting intensity increases. I'm assuming this means that instead of redrawing the code coverage, it's just layering the code coverage over the existing rendered panel. During my testing I found that if thing.go shared it's panel with another file in a tab, switching tabs would reset the code highlighting to the expected state.
If you then select a file in another panel, and focus back on thing.go the issue will appear again.
Once the issue has occurred, you can not use the right click menu Go: Toggle Test Coverage In Current Package to hide the code coverage highlighting

I'm not 100% sure what the issue is, or what component is the culprit. I'm assuming that this is a problem with the vscode-go plugin.

Steps to Reproduce:

  1. Start VScode however you like
  2. Create a simple go file with a few functions to test
  3. Create a simple unit test for those functions
  4. Open the go file and unit test file in vscode
  5. Select the unit test files tab, right click, and select split right
  6. Close the unit test files tab in the left panel.
  7. Execute the unit test
  • Click run package tests in unit test file, and click to bring focus back into the go file
  • OR: Right click in the go file and click Go: Toggle Test Coverage In Current Package
  1. Switch focus to the unit test file in the right panel by clicking inside of the open file
  2. Switch focus to the go file in the left panel by clicking inside of the open file

Here's a gif demonstrating the highlighting issue

vscode-go-issue-2045

Example code
thing.go

package thing

import (
	"bytes"
)

func function(times int) string {
	output := bytes.Buffer{}
	for i := 0; i < times; i++ {
		output.WriteRune('A')
	}

	return output.String()
}

thing_test.go

package thing

import (
	"testing"
)

func Test_function(t *testing.T) {
	type args struct {
		times int
	}
	tests := []struct {
		name string
		args args
		want string
	}{
		{"sanity-4-As", args{4}, "AAAA"},
		{"sanity-4-As", args{8}, "AAAAAAAA"},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := function(tt.args.times); got != tt.want {
				t.Errorf("function() = %v, want %v", got, tt.want)
			}
		})
	}
}
@ramya-rao-a
Copy link
Contributor

Thanks for reporting @SteelPhase!

I'm assuming this means that instead of redrawing the code coverage, it's just layering the code coverage over the existing rendered panel.

I believe so too.

PRs are welcome to fix this bug.

Code Pointers:

@ramya-rao-a
Copy link
Contributor

This is fixed with #2047

Until I release an update, you can get the fix using the beta version of this extension

@ramya-rao-a
Copy link
Contributor

The fix is now out in the latest update to this extension (0.7.0)
Thanks @diogogmt!

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants