@@ -512,21 +512,6 @@ function getSearchElement() {
512512 var OUTPUT_DATA = 1 ;
513513 var params = getQueryStringParams ( ) ;
514514
515- // Set the crate filter from saved storage, if the current page has the saved crate filter.
516- //
517- // If not, ignore the crate filter -- we want to support filtering for crates on sites like
518- // doc.rust-lang.org where the crates may differ from page to page while on the same domain.
519- var savedCrate = getCurrentValue ( "rustdoc-saved-filter-crate" ) ;
520- if ( savedCrate !== null ) {
521- onEachLazy ( document . getElementById ( "crate-search" ) . getElementsByTagName ( "option" ) ,
522- function ( e ) {
523- if ( e . value === savedCrate ) {
524- document . getElementById ( "crate-search" ) . value = e . value ;
525- return true ;
526- }
527- } ) ;
528- }
529-
530515 // Populate search bar with query string search term when provided,
531516 // but only if the input bar is empty. This avoid the obnoxious issue
532517 // where you start trying to do a search, and the index loads, and
@@ -2620,11 +2605,21 @@ function getSearchElement() {
26202605 }
26212606 return 0 ;
26222607 } ) ;
2608+ var savedCrate = getCurrentValue ( "rustdoc-saved-filter-crate" ) ;
26232609 for ( var i = 0 ; i < crates_text . length ; ++ i ) {
26242610 var option = document . createElement ( "option" ) ;
26252611 option . value = crates_text [ i ] ;
26262612 option . innerText = crates_text [ i ] ;
26272613 elem . appendChild ( option ) ;
2614+ // Set the crate filter from saved storage, if the current page has the saved crate
2615+ // filter.
2616+ //
2617+ // If not, ignore the crate filter -- we want to support filtering for crates on sites
2618+ // like doc.rust-lang.org where the crates may differ from page to page while on the
2619+ // same domain.
2620+ if ( crates_text [ i ] === savedCrate ) {
2621+ elem . value = savedCrate ;
2622+ }
26282623 }
26292624 }
26302625
0 commit comments