Skip to content

Commit

Permalink
Fix inverted coverage ranges and clamp column numbers to >=1 (#363)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
hyperair and ArtiomTr authored Apr 23, 2023
1 parent 952a059 commit aaee641
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 643 deletions.
18 changes: 8 additions & 10 deletions src/annotations/createCoverageAnnotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ const getLocation = (
start_column?: number;
end_column?: number;
} => ({
start_line: start.line,
end_line: end.line,
start_column:
start.line === end.line && start.column !== null && end.column !== null
? start.column
: undefined,
end_column:
start.line === end.line && start.column !== null && end.column !== null
? end.column
: undefined,
start_line: Math.min(start.line, end.line),
end_line: Math.max(end.line),
...(start.line === end.line && start.column != null && end.column != null
? {
start_column: Math.max(1, Math.min(start.column, end.column)),
end_column: Math.max(1, start.column, end.column),
}
: {}),
});

export const createCoverageAnnotations = (
Expand Down
Loading

0 comments on commit aaee641

Please sign in to comment.