Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/librustdoc/html/static/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,8 @@ window.initSearch = function(rawSearchIndex) {
var actives = [[], [], []];
// "current" is used to know which tab we're looking into.
var current = 0;
onEachLazy(document.getElementById("results").childNodes, function(e) {
var results = document.getElementById("results").childNodes;
onEachLazy(results, function(e) {
onEachLazy(e.getElementsByClassName("highlighted"), function(h_e) {
actives[current].push(h_e);
});
Expand All @@ -953,7 +954,6 @@ window.initSearch = function(rawSearchIndex) {
if (e.ctrlKey) { // Going through result tabs.
printTab(currentTab > 1 ? 0 : currentTab + 1);
} else if (!actives[currentTab].length) {
var results = document.getElementById("results").childNodes;
if (results.length > 0) {
var res = results[currentTab].getElementsByClassName("result");
if (res.length > 0) {
Expand All @@ -969,6 +969,14 @@ window.initSearch = function(rawSearchIndex) {
if (actives[currentTab].length) {
document.location.href =
actives[currentTab][0].getElementsByTagName("a")[0].href;
} else {
if (results.length > 0) {
var firstRes = results[0].getElementsByClassName("result");
if (firstRes.length > 0) {
document.location.href =
firstRes[0].getElementsByTagName("a")[0].href;
}
}
}
} else if (e.which === 16) { // shift
// Does nothing, it's just to avoid losing "focus" on the highlighted element.
Expand Down