@@ -1576,14 +1576,18 @@ function defocusSearchBar() {
15761576 }
15771577
15781578 function showResults ( results ) {
1579- if ( results . others . length === 1 &&
1580- getCurrentValue ( "rustdoc-go-to-only-result" ) === "true" ) {
1579+ var search = getSearchElement ( ) ;
1580+ if ( results . others . length === 1
1581+ && getCurrentValue ( "rustdoc-go-to-only-result" ) === "true"
1582+ && ( ! search . firstChild || search . firstChild . innerText !== getSearchLoadingText ( ) ) )
1583+ {
15811584 var elem = document . createElement ( "a" ) ;
15821585 elem . href = results . others [ 0 ] . href ;
15831586 elem . style . display = "none" ;
15841587 // For firefox, we need the element to be in the DOM so it can be clicked.
15851588 document . body . appendChild ( elem ) ;
15861589 elem . click ( ) ;
1590+ return ;
15871591 }
15881592 var query = getQuery ( search_input . value ) ;
15891593
@@ -1602,7 +1606,6 @@ function defocusSearchBar() {
16021606 "</div><div id=\"results\">" +
16031607 ret_others [ 0 ] + ret_in_args [ 0 ] + ret_returned [ 0 ] + "</div>" ;
16041608
1605- var search = getSearchElement ( ) ;
16061609 search . innerHTML = output ;
16071610 showSearchResults ( search ) ;
16081611 var tds = search . getElementsByTagName ( "td" ) ;
@@ -2679,6 +2682,10 @@ function defocusSearchBar() {
26792682 }
26802683 }
26812684
2685+ function getSearchLoadingText ( ) {
2686+ return "Loading search results..." ;
2687+ }
2688+
26822689 if ( search_input ) {
26832690 search_input . onfocus = function ( ) {
26842691 putBackSearch ( this ) ;
@@ -2688,7 +2695,7 @@ function defocusSearchBar() {
26882695 var params = getQueryStringParams ( ) ;
26892696 if ( params && params . search ) {
26902697 var search = getSearchElement ( ) ;
2691- search . innerHTML = "<h3 style=\"text-align: center;\">Loading search results... </h3>" ;
2698+ search . innerHTML = "<h3 style=\"text-align: center;\">" + getSearchLoadingText ( ) + " </h3>";
26922699 showSearchResults ( search ) ;
26932700 }
26942701
0 commit comments