File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -4448,7 +4448,6 @@ function updateSearchHistory(url) {
44484448async function search ( forced ) {
44494449 const query = DocSearch . parseQuery ( searchState . input . value . trim ( ) ) ;
44504450 let filterCrates = getFilterCrates ( ) ;
4451-
44524451 if ( ! forced && query . userQuery === currentResults ) {
44534452 if ( query . userQuery . length > 0 ) {
44544453 putBackSearch ( ) ;
@@ -4650,6 +4649,15 @@ function updateCrate(ev) {
46504649 // If we don't remove it from the URL, it'll be picked up again by the search.
46514650 const query = searchState . input . value . trim ( ) ;
46524651 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 ;
46534661 }
46544662 // In case you "cut" the entry from the search input, then change the crate filter
46554663 // 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