@@ -521,21 +521,6 @@ function getSearchElement() {
521521 var OUTPUT_DATA = 1 ;
522522 var params = getQueryStringParams ( ) ;
523523
524- // Set the crate filter from saved storage, if the current page has the saved crate filter.
525- //
526- // If not, ignore the crate filter -- we want to support filtering for crates on sites like
527- // doc.rust-lang.org where the crates may differ from page to page while on the same domain.
528- var savedCrate = getCurrentValue ( "rustdoc-saved-filter-crate" ) ;
529- if ( savedCrate !== null ) {
530- onEachLazy ( document . getElementById ( "crate-search" ) . getElementsByTagName ( "option" ) ,
531- function ( e ) {
532- if ( e . value === savedCrate ) {
533- document . getElementById ( "crate-search" ) . value = e . value ;
534- return true ;
535- }
536- } ) ;
537- }
538-
539524 // Populate search bar with query string search term when provided,
540525 // but only if the input bar is empty. This avoid the obnoxious issue
541526 // where you start trying to do a search, and the index loads, and
@@ -2629,11 +2614,21 @@ function getSearchElement() {
26292614 }
26302615 return 0 ;
26312616 } ) ;
2617+ var savedCrate = getCurrentValue ( "rustdoc-saved-filter-crate" ) ;
26322618 for ( var i = 0 ; i < crates_text . length ; ++ i ) {
26332619 var option = document . createElement ( "option" ) ;
26342620 option . value = crates_text [ i ] ;
26352621 option . innerText = crates_text [ i ] ;
26362622 elem . appendChild ( option ) ;
2623+ // Set the crate filter from saved storage, if the current page has the saved crate
2624+ // filter.
2625+ //
2626+ // If not, ignore the crate filter -- we want to support filtering for crates on sites
2627+ // like doc.rust-lang.org where the crates may differ from page to page while on the
2628+ // same domain.
2629+ if ( crates_text [ i ] === savedCrate ) {
2630+ elem . value = savedCrate ;
2631+ }
26372632 }
26382633
26392634 if ( search_input ) {
0 commit comments