diff --git a/coverage/htmlfiles/coverage_html.js b/coverage/htmlfiles/coverage_html.js index a28c1bef8..0a859a537 100644 --- a/coverage/htmlfiles/coverage_html.js +++ b/coverage/htmlfiles/coverage_html.js @@ -81,7 +81,32 @@ function sortColumn(th) { .forEach(tr => tr.parentElement.appendChild(tr)); // Save the sort order for next time. - localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({column, direction})); + if (th.id !== "region") { + let th_id = "file"; // Sort by file if we don't have a column id + let current_direction = direction; + const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE); + if (stored_list) { + ({th_id, direction} = JSON.parse(stored_list)) + } + localStorage.setItem(coverage.INDEX_SORT_STORAGE, JSON.stringify({ + "th_id": th.id, + "direction": current_direction + })); + if (th.id !== th_id || document.getElementById("region")) { + // Sort column has changed, unset sorting by function or class. + localStorage.setItem(coverage.SORTED_BY_REGION, JSON.stringify({ + "by_region": false, + "region_direction": current_direction + })); + } + } + else { + // Sort column has changed to by function or class, remember that. + localStorage.setItem(coverage.SORTED_BY_REGION, JSON.stringify({ + "by_region": true, + "region_direction": direction + })); + } } // Find all the elements with data-shortcut attribute, and use them to assign a shortcut key. @@ -223,18 +248,39 @@ coverage.wire_up_sorting = function () { ); // Look for a localStorage item containing previous sort settings: - var column = 0, direction = "ascending"; + let th_id = "file", direction = "ascending"; const stored_list = localStorage.getItem(coverage.INDEX_SORT_STORAGE); if (stored_list) { - ({column, direction} = JSON.parse(stored_list)); + ({th_id, direction} = JSON.parse(stored_list)); + } + let by_region = false, region_direction = "ascending"; + const sorted_by_region = localStorage.getItem(coverage.SORTED_BY_REGION); + if (sorted_by_region) { + ({ + by_region, + region_direction + } = JSON.parse(sorted_by_region)); } - const th = document.querySelector("[data-sortable]").tHead.rows[0].cells[column]; // nosemgrep: eslint.detect-object-injection + const region_id = "region"; + if (by_region && document.getElementById(region_id)) { + direction = region_direction; + } + // If we are in a page that has a column with id of "region", sort on + // it if the last sort was by function or class. + let th; + if (document.getElementById(region_id)) { + th = document.getElementById(by_region ? region_id : th_id); + } + else { + th = document.getElementById(th_id); + } th.setAttribute("aria-sort", direction === "ascending" ? "descending" : "ascending"); th.click() }; coverage.INDEX_SORT_STORAGE = "COVERAGE_INDEX_SORT_2"; +coverage.SORTED_BY_REGION = "COVERAGE_SORT_REGION"; // Loaded on index.html coverage.index_ready = function () { diff --git a/coverage/htmlfiles/index.html b/coverage/htmlfiles/index.html index 2c1dee02f..f75d18b43 100644 --- a/coverage/htmlfiles/index.html +++ b/coverage/htmlfiles/index.html @@ -82,18 +82,18 @@

{# The title="" attr doesn't work in Safari. #} - File + File {% if column2 %} - {{ column2 }} + {{ column2 }} {% endif %} - statements - missing - excluded + statements + missing + excluded {% if has_arcs %} - branches - partial + branches + partial {% endif %} - coverage + coverage diff --git a/tests/gold/html/a/class_index.html b/tests/gold/html/a/class_index.html index 9e01afdcb..54f6e6c44 100644 --- a/tests/gold/html/a/class_index.html +++ b/tests/gold/html/a/class_index.html @@ -4,8 +4,8 @@ Coverage report - - + +
@@ -55,7 +55,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300

@@ -63,12 +63,12 @@

- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -96,7 +96,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:03 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - - - + + + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300

FileclassstatementsmissingexcludedbranchespartialcoverageFileclassstatementsmissingexcludedbranchespartialcoverage
- - - - - - - - + + + + + + + + @@ -138,7 +138,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300

FilefunctionstatementsmissingexcludedbranchespartialcoverageFilefunctionstatementsmissingexcludedbranchespartialcoverage
- - - - - - - + + + + + + + @@ -104,7 +104,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:03 -0300

FilestatementsmissingexcludedbranchespartialcoverageFilestatementsmissingexcludedbranchespartialcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -96,7 +96,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:03 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -124,7 +124,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -96,7 +96,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:02 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:13 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -96,7 +96,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:02 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -124,7 +124,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -124,7 +124,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -117,7 +117,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:02 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -116,7 +116,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -116,7 +116,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -110,7 +110,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:03 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -103,7 +103,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:03 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -116,7 +116,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -116,7 +116,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -110,7 +110,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:02 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -103,7 +103,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:02 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + - - + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 08:10 -0400 + created at 2024-04-28 13:17 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
/private/var/folders/6j/khn0mcrj35d1k3yylpl8zl080000gn/T/pytest-of-ned/pytest-293/t40/othersrc/other.py(no class)C:\Users\ddini\AppData\Local\Temp\pytest-of-ddini\pytest-9\popen-gw6\t1\othersrc\other.py(no class) 1 0 0
- - - - - - + + + + + + - - + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 08:10 -0400 + created at 2024-04-28 13:17 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
/private/var/folders/6j/khn0mcrj35d1k3yylpl8zl080000gn/T/pytest-of-ned/pytest-293/t40/othersrc/other.py(no function)C:\Users\ddini\AppData\Local\Temp\pytest-of-ddini\pytest-9\popen-gw6\t1\othersrc\other.py(no function) 1 0 0
- - - - - + + + + + - + @@ -103,12 +103,12 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 08:10 -0400 + created at 2024-04-28 13:17 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
/private/var/folders/6j/khn0mcrj35d1k3yylpl8zl080000gn/T/pytest-of-ned/pytest-293/t40/othersrc/other.pyC:\Users\ddini\AppData\Local\Temp\pytest-of-ddini\pytest-9\popen-gw6\t1\othersrc\other.py 1 0 0
- - - - - - - - + + + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 10:14 -0400 + created at 2024-04-29 17:40 -0300

FileclassstatementsmissingexcludedbranchespartialcoverageFileclassstatementsmissingexcludedbranchespartialcoverage
- - - - - - - - + + + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 10:14 -0400 + created at 2024-04-29 17:40 -0300

FilefunctionstatementsmissingexcludedbranchespartialcoverageFilefunctionstatementsmissingexcludedbranchespartialcoverage
- - - - - - - + + + + + + + @@ -104,7 +104,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 10:14 -0400 + created at 2024-04-29 17:40 -0300

FilestatementsmissingexcludedbranchespartialcoverageFilestatementsmissingexcludedbranchespartialcoverage
- - - - - - - - + + + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedbranchespartialcoverageFileclassstatementsmissingexcludedbranchespartialcoverage
- - - - - - - - + + + + + + + + @@ -108,7 +108,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedbranchespartialcoverageFilefunctionstatementsmissingexcludedbranchespartialcoverage
- - - - - - - + + + + + + + @@ -104,7 +104,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:02 -0300

FilestatementsmissingexcludedbranchespartialcoverageFilestatementsmissingexcludedbranchespartialcoverage
- - - - - - + + + + + + @@ -101,7 +101,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 16:04 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -101,7 +101,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 16:04 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -97,7 +97,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 16:04 -0400 + created at 2024-04-25 23:02 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FileclassstatementsmissingexcludedcoverageFileclassstatementsmissingexcludedcoverage
- - - - - - + + + + + + @@ -100,7 +100,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-28 13:14 -0300

FilefunctionstatementsmissingexcludedcoverageFilefunctionstatementsmissingexcludedcoverage
- - - - - + + + + + @@ -96,7 +96,7 @@

coverage.py v7.5.1a0.dev1, - created at 2024-04-24 09:22 -0400 + created at 2024-04-25 23:03 -0300

FilestatementsmissingexcludedcoverageFilestatementsmissingexcludedcoverage