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

go.coverShowCounts: true not works with go.coverageDecorator.type: "gutter" #3588

Open
d-enk opened this issue Nov 2, 2024 · 4 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@d-enk
Copy link

d-enk commented Nov 2, 2024

"go.coverShowCounts": true,

image

if change type without resetting coverage

"go.coverageDecorator": {
  "type": "gutter",
},

works like expected
image

but if rerun test - counter disappears
image

@gopherbot gopherbot added this to the Untriaged milestone Nov 2, 2024
@ansaba
Copy link

ansaba commented Nov 5, 2024

cc: @h9jiang

@ansaba ansaba added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 7, 2024
@ansaba ansaba modified the milestones: Untriaged, vscode-go/backlog Nov 7, 2024
@h9jiang
Copy link
Member

h9jiang commented Nov 8, 2024

I'm able to reproduce the behavior you saw.

First, run test using configuration below

"go.coverageDecorator": {
    "type":"highlight",
}

The --1-- showed up in VSCode. If I change the type from highlight to gutter, rerun the test, the --1-- disappear. I can find the source code which controls this behavior.

Based on the comment // irrelevant for "gutter": If the type is "highlight", the elaborate function returns both the highlight of the code as well as the count number before this snippet of code. If the type of the decorator is "gutter", neither will be rendered.

image

See goCover.ts

I'm still new to this, but I think the purpose of the decorator.Type == "gutter" means we should only render things in the gutter without introducing any text or decorations in the source code itself. (Keeping the code clean and untouched).

But the "go.coverShowCounts": true, is a configuration in parallel with "go.coverageDecorator". I did not expect to see them impacting each other. Is there any place we can render a number in gutter. (my guess is no) 🤔

@pjweinb @hyangah for suggestions.

If we ever decided to render the count in "gutter" type, I'm afraid we will need to have some background highlight for this. And this background highlight should not inherit from the go.coverageDecorator.coveredBorderColor go.coverageDecorator.uncoveredBorderColor to avoid confusion.

@pjweinb
Copy link

pjweinb commented Nov 8, 2024

h9jiang is right. Here's my explanation: The leftover --1-- that d-enk sees is a bug in the implementation. When the settings change, the code tries to remove all the coverage information, but it's failing to remove the counts, which are inlay hints.

I think interpolating counts in gutter mode would be a new feature.

@firelizzard18
Copy link
Contributor

Once the next preview version of gopls (0.17) and vscode-go (0.43) are released, you could use Go Companion's test coverage support. Coverage decorations are handled via VSCode's native testing and test coverage support which seems pretty solid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants