Skip to content

Commit aaee641

Browse files
hyperairArtiomTr
andauthored
Fix inverted coverage ranges and clamp column numbers to >=1 (#363)
* Avoid setting {start,end}_column to undefined in annotations * Deal with inverted location ranges in coverage annotations * Update test snapshots * Fixed eslint issues --------- Co-authored-by: Artiom Tretjakovas <[email protected]>
1 parent 952a059 commit aaee641

File tree

2 files changed

+9
-643
lines changed

2 files changed

+9
-643
lines changed

src/annotations/createCoverageAnnotations.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ const getLocation = (
1414
start_column?: number;
1515
end_column?: number;
1616
} => ({
17-
start_line: start.line,
18-
end_line: end.line,
19-
start_column:
20-
start.line === end.line && start.column !== null && end.column !== null
21-
? start.column
22-
: undefined,
23-
end_column:
24-
start.line === end.line && start.column !== null && end.column !== null
25-
? end.column
26-
: undefined,
17+
start_line: Math.min(start.line, end.line),
18+
end_line: Math.max(end.line),
19+
...(start.line === end.line && start.column != null && end.column != null
20+
? {
21+
start_column: Math.max(1, Math.min(start.column, end.column)),
22+
end_column: Math.max(1, start.column, end.column),
23+
}
24+
: {}),
2725
});
2826

2927
export const createCoverageAnnotations = (

0 commit comments

Comments
 (0)