@@ -1576,14 +1576,18 @@ function defocusSearchBar() {
1576
1576
}
1577
1577
1578
1578
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
+ {
1581
1584
var elem = document . createElement ( "a" ) ;
1582
1585
elem . href = results . others [ 0 ] . href ;
1583
1586
elem . style . display = "none" ;
1584
1587
// For firefox, we need the element to be in the DOM so it can be clicked.
1585
1588
document . body . appendChild ( elem ) ;
1586
1589
elem . click ( ) ;
1590
+ return ;
1587
1591
}
1588
1592
var query = getQuery ( search_input . value ) ;
1589
1593
@@ -1602,7 +1606,6 @@ function defocusSearchBar() {
1602
1606
"</div><div id=\"results\">" +
1603
1607
ret_others [ 0 ] + ret_in_args [ 0 ] + ret_returned [ 0 ] + "</div>" ;
1604
1608
1605
- var search = getSearchElement ( ) ;
1606
1609
search . innerHTML = output ;
1607
1610
showSearchResults ( search ) ;
1608
1611
var tds = search . getElementsByTagName ( "td" ) ;
@@ -2679,6 +2682,10 @@ function defocusSearchBar() {
2679
2682
}
2680
2683
}
2681
2684
2685
+ function getSearchLoadingText ( ) {
2686
+ return "Loading search results..." ;
2687
+ }
2688
+
2682
2689
if ( search_input ) {
2683
2690
search_input . onfocus = function ( ) {
2684
2691
putBackSearch ( this ) ;
@@ -2688,7 +2695,7 @@ function defocusSearchBar() {
2688
2695
var params = getQueryStringParams ( ) ;
2689
2696
if ( params && params . search ) {
2690
2697
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>";
2692
2699
showSearchResults ( search ) ;
2693
2700
}
2694
2701
0 commit comments