@@ -17,6 +17,7 @@ import {
1717 componentsStorageKey ,
1818 flagsStorageKey ,
1919 lineSelector ,
20+ noVirtLineSelector ,
2021} from "./utils/constants" ;
2122import {
2223 animateAndAnnotateLines ,
@@ -228,6 +229,7 @@ async function process(metadata: FileMetadata): Promise<void> {
228229
229230 globals . coverageReport = coverageReport ;
230231 animateAndAnnotateLines ( lineSelector , annotateLine ) ;
232+ animateAndAnnotateLines ( noVirtLineSelector , annotateLine ) ;
231233}
232234
233235async function promptPastReport ( metadata : FileMetadata ) : Promise < void > {
@@ -275,6 +277,7 @@ function createCoverageButton() {
275277 const isInactive = codecovButton . getAttribute ( "data-inactive" ) ;
276278 if ( isInactive == "true" ) {
277279 animateAndAnnotateLines ( lineSelector , annotateLine ) ;
280+ animateAndAnnotateLines ( noVirtLineSelector , annotateLine ) ;
278281 codecovButton . removeAttribute ( "data-inactive" ) ;
279282 codecovButton . style . opacity = "1" ;
280283 } else {
@@ -325,7 +328,15 @@ function updateButton(text: string) {
325328}
326329
327330function annotateLine ( line : HTMLElement ) {
328- const lineNumber = parseInt ( line . getAttribute ( "data-key" ) ! ) + 1 ;
331+ let lineNumber = _ . parseInt ( line . getAttribute ( "data-key" ) ! ) + 1 ;
332+ const lineNumberString = line . getAttribute ( "data-key" ) ;
333+ if ( lineNumberString ) {
334+ lineNumber = _ . parseInt ( lineNumberString ) + 1 ; // Virtualized lines have data-key="{number - 1}"
335+ } else {
336+ const noVirtLineNumberString = line . getAttribute ( "id" ) ;
337+ if ( ! noVirtLineNumberString ) return ;
338+ lineNumber = _ . parseInt ( noVirtLineNumberString . slice ( 2 ) ) ; // Non-virtualized lines have id="LC{number}"
339+ }
329340 // called from "Coverage: N/A" button on-click handler
330341 if ( ! globals . coverageReport ) {
331342 return ;
0 commit comments