@@ -445,6 +445,21 @@ if (!DOMTokenList.prototype.remove) {
445
445
var OUTPUT_DATA = 1 ;
446
446
var params = getQueryStringParams ( ) ;
447
447
448
+ // Set the crate filter from saved storage, if the current page has the saved crate filter.
449
+ //
450
+ // If not, ignore the crate filter -- we want to support filtering for crates on sites like
451
+ // doc.rust-lang.org where the crates may differ from page to page while on the same domain.
452
+ var savedCrate = getCurrentValue ( "rustdoc-saved-filter-crate" ) ;
453
+ if ( savedCrate !== null ) {
454
+ onEachLazy ( document . getElementById ( "crate-search" ) . getElementsByTagName ( "option" ) ,
455
+ function ( e ) {
456
+ if ( e . value === savedCrate ) {
457
+ document . getElementById ( "crate-search" ) . value = e . value ;
458
+ return true ;
459
+ }
460
+ } ) ;
461
+ }
462
+
448
463
// Populate search bar with query string search term when provided,
449
464
// but only if the input bar is empty. This avoid the obnoxious issue
450
465
// where you start trying to do a search, and the index loads, and
@@ -1658,9 +1673,10 @@ if (!DOMTokenList.prototype.remove) {
1658
1673
} ;
1659
1674
search_input . onpaste = search_input . onchange ;
1660
1675
1661
- var selectCrate = document . getElementById ( ' crate-search' ) ;
1676
+ var selectCrate = document . getElementById ( " crate-search" ) ;
1662
1677
if ( selectCrate ) {
1663
1678
selectCrate . onchange = function ( ) {
1679
+ updateLocalStorage ( "rustdoc-saved-filter-crate" , selectCrate . value ) ;
1664
1680
search ( undefined , true ) ;
1665
1681
} ;
1666
1682
}
@@ -2496,7 +2512,7 @@ if (!DOMTokenList.prototype.remove) {
2496
2512
}
2497
2513
2498
2514
function addSearchOptions ( crates ) {
2499
- var elem = document . getElementById ( ' crate-search' ) ;
2515
+ var elem = document . getElementById ( " crate-search" ) ;
2500
2516
2501
2517
if ( ! elem ) {
2502
2518
return ;
0 commit comments