Skip to content

Commit

Permalink
Rollup merge of #105016 - GuillaumeGomez:load-sentence-rustdoc, r=not…
Browse files Browse the repository at this point in the history
…riddle

Add sentence when rustdoc search is running

This is a small improvement, mostly relevant on big search indexes. As soon as the search starts, it'll display:

![image](https://user-images.githubusercontent.com/3050060/204336014-4660634a-09a0-4d5e-a772-d7e1e810dddf.png)

cc ``@jsha``
r? ``@notriddle``
  • Loading branch information
matthiaskrgr authored Nov 29, 2022
2 parents d5d79ac + 20f389d commit 1ad234c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,15 @@ function loadCss(cssUrl) {

const params = searchState.getQueryStringParams();
if (params.search !== undefined) {
const search = searchState.outputElement();
search.innerHTML = "<h3 class=\"search-loading\">" +
searchState.loadingText + "</h3>";
searchState.showResults(search);
searchState.setLoadingSearch();
loadSearch();
}
},
setLoadingSearch: () => {
const search = searchState.outputElement();
search.innerHTML = "<h3 class=\"search-loading\">" + searchState.loadingText + "</h3>";
searchState.showResults(search);
},
};

function getPageId() {
Expand Down
10 changes: 6 additions & 4 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1766,21 +1766,23 @@ function initSearch(rawSearchIndex) {
* @param {boolean} [forced]
*/
function search(e, forced) {
const params = searchState.getQueryStringParams();
const query = parseQuery(searchState.input.value.trim());

if (e) {
e.preventDefault();
}

const query = parseQuery(searchState.input.value.trim());
let filterCrates = getFilterCrates();

if (!forced && query.userQuery === currentResults) {
if (query.userQuery.length > 0) {
putBackSearch();
}
return;
}

let filterCrates = getFilterCrates();
searchState.setLoadingSearch();

const params = searchState.getQueryStringParams();

// In case we have no information about the saved crate and there is a URL query parameter,
// we override it with the URL query parameter.
Expand Down

0 comments on commit 1ad234c

Please sign in to comment.