Skip to content

Commit

Permalink
rustdoc-search: give longer notification for type corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Apr 19, 2023
1 parent 4c11822 commit b6f81e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -1996,8 +1996,13 @@ function initSearch(rawSearchIndex) {
}

if (results.query.correction !== null) {
output += "<h3 class=\"search-corrections\">Showing results for " +
`"${results.query.correction}".</h3>`;
const orig = results.query.returned.length > 0
? results.query.returned[0].name
: results.query.elems[0].name;
output += "<h3 class=\"search-corrections\">" +
`Type "${orig}" not found. ` +
"Showing results for " +
`"${results.query.correction}" instead.</h3>`;
}

const resultsElem = document.createElement("div");
Expand Down
6 changes: 3 additions & 3 deletions tests/rustdoc-gui/search-corrections.goml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assert-css: (".search-corrections", {
})
assert-text: (
".search-corrections",
"Showing results for \"notablestructwithlongname\"."
"Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
)

// Corrections do get shown on the "In Return Type" tab.
Expand All @@ -33,7 +33,7 @@ assert-css: (".search-corrections", {
})
assert-text: (
".search-corrections",
"Showing results for \"notablestructwithlongname\"."
"Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
)

// Now, explicit return values
Expand All @@ -50,5 +50,5 @@ assert-css: (".search-corrections", {
})
assert-text: (
".search-corrections",
"Showing results for \"notablestructwithlongname\"."
"Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
)

0 comments on commit b6f81e0

Please sign in to comment.