File tree 1 file changed +9
-1
lines changed
src/librustdoc/html/static/js
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -4448,7 +4448,6 @@ function updateSearchHistory(url) {
4448
4448
async function search ( forced ) {
4449
4449
const query = DocSearch . parseQuery ( searchState . input . value . trim ( ) ) ;
4450
4450
let filterCrates = getFilterCrates ( ) ;
4451
-
4452
4451
if ( ! forced && query . userQuery === currentResults ) {
4453
4452
if ( query . userQuery . length > 0 ) {
4454
4453
putBackSearch ( ) ;
@@ -4650,6 +4649,15 @@ function updateCrate(ev) {
4650
4649
// If we don't remove it from the URL, it'll be picked up again by the search.
4651
4650
const query = searchState . input . value . trim ( ) ;
4652
4651
updateSearchHistory ( buildUrl ( query , null ) ) ;
4652
+ } else {
4653
+ const crate = ev . target . value ;
4654
+ // add/update the `crate:` syntax in the search bar
4655
+ let newquery = searchState . input . value
4656
+ . replace ( / c r a t e : [ a - z A - Z _ 0 - 9 ] + / , "crate:" + crate ) ;
4657
+ if ( ! newquery . includes ( "crate:" ) ) {
4658
+ newquery = "crate:" + crate + " " + searchState . input . value ;
4659
+ }
4660
+ searchState . input . value = newquery ;
4653
4661
}
4654
4662
// In case you "cut" the entry from the search input, then change the crate filter
4655
4663
// before paste back the previous search, you get the old search results without
You can’t perform that action at this time.
0 commit comments