Skip to content

Commit

Permalink
fix: restore html report selection highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Apr 11, 2021
1 parent 704a259 commit 9c47249
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Unreleased
- Coverage will no longer generate "Already imported a file that will be
measured" warnings about coverage itself (`issue 905`_).

- The HTML report uses j/k to move up and down among the highlighted chunks of
code. They used to highlight the current chunk, but 5.0 broke that behavior.
Now the highlighting is working again.

- The JSON report now includes ``percent_covered_display``, a string with the
total percentage, rounded to the same number of decimal places as the other
reports' totals.
Expand Down
9 changes: 2 additions & 7 deletions coverage/htmlfiles/coverage_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,6 @@ coverage.line_elt = function (n) {
return $("#t" + n);
};

// Return the nth line number div.
coverage.num_elt = function (n) {
return $("#n" + n);
};

// Set the selection. b and e are line numbers.
coverage.set_sel = function (b, e) {
// The first line selected.
Expand Down Expand Up @@ -514,9 +509,9 @@ coverage.show_selection = function () {
var c = coverage;

// Highlight the lines in the chunk
$(".linenos .highlight").removeClass("highlight");
$("#source .highlight").removeClass("highlight");
for (var probe = c.sel_begin; probe > 0 && probe < c.sel_end; probe++) {
c.num_elt(probe).addClass("highlight");
c.line_elt(probe).addClass("highlight");
}

c.scroll_to_selection();
Expand Down

0 comments on commit 9c47249

Please sign in to comment.