diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 8f7cd244c2f..e9a3cfd908e 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -39,6 +39,13 @@ "associatedconstant", "union"]; + // On the search screen, so you remain on the last tab you opened. + // + // 0 for "Types/modules" + // 1 for "As parameters" + // 2 for "As return value" + var currentTab = 0; + function hasClass(elem, className) { if (elem && className && elem.className) { var elemClass = elem.className; @@ -758,7 +765,7 @@ var output = ''; if (array.length > 0) { - output = ``; + output = '
'; var shown = []; array.forEach(function(item) { @@ -812,7 +819,7 @@ }); output += '
'; } else { - output = `
No results :(
` + + output = '
No results :(
' + 'Try on DuckDuckGo?
'; @@ -820,6 +827,13 @@ return output; } + function makeTabHeader(tabNb, text) { + if (currentTab === tabNb) { + return '
' + text + '
'; + } + return '
' + text + '
'; + } + function showResults(results) { var output, query = getQuery(); @@ -827,9 +841,10 @@ output = '

Results for ' + escape(query.query) + (query.type ? ' (type: ' + escape(query.type) + ')' : '') + '

' + '
' + - '
Types/modules
' + - '
As parameters
' + - '
As return value
'; + makeTabHeader(0, "Types/modules") + + makeTabHeader(1, "As parameters") + + makeTabHeader(2, "As return value") + + '
'; output += addTab(results['others'], query); output += addTab(results['in_args'], query, false); @@ -1405,6 +1420,9 @@ // In the search display, allows to switch between tabs. function printTab(nb) { + if (nb === 0 || nb === 1 || nb === 2) { + currentTab = nb; + } var nb_copy = nb; onEach(document.getElementById('titles').childNodes, function(elem) { if (nb_copy === 0) {