Skip to content

Commit

Permalink
fix: Line coverage off by one in VirtualFileRenderer (#3143)
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmurray-codecov authored Aug 21, 2024
1 parent 845a181 commit 3ed348a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ui/VirtualFileRenderer/VirtualFileRenderer.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ const code = `<Breadcrumb
/>`

const coverageData = {
0: 'H',
1: 'M',
2: 'P',
1: 'H',
2: 'M',
3: 'P',
} as unknown as Dictionary<'H' | 'M' | 'P'>

let testLocation: ReturnType<typeof useLocation>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/VirtualFileRenderer/VirtualFileRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const CodeBody = ({
<div className="relative z-[2] h-full w-[86px] min-w-[86px] pr-[10px]">
{virtualizer.getVirtualItems().map((item) => {
const lineNumber = item.index + 1
const coverageValue = coverage?.[item.index]
const coverageValue = coverage?.[lineNumber]

return (
<div
Expand Down Expand Up @@ -243,7 +243,7 @@ const CodeBody = ({
<ColorBar
lineNumber={lineNumber}
locationHash={location.hash}
coverage={coverage?.[item.index]}
coverage={coverage?.[lineNumber]}
/>
<div
className="w-full"
Expand Down

0 comments on commit 3ed348a

Please sign in to comment.