Skip to content

Commit b6f81e0

Browse files
committed
rustdoc-search: give longer notification for type corrections
1 parent 4c11822 commit b6f81e0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/librustdoc/html/static/js/search.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1996,8 +1996,13 @@ function initSearch(rawSearchIndex) {
19961996
}
19971997

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

20032008
const resultsElem = document.createElement("div");

tests/rustdoc-gui/search-corrections.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ assert-css: (".search-corrections", {
2222
})
2323
assert-text: (
2424
".search-corrections",
25-
"Showing results for \"notablestructwithlongname\"."
25+
"Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
2626
)
2727

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

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

0 commit comments

Comments
 (0)