Skip to content

Commit

Permalink
rustdoc-search: use more descriptive "x not found; y instead" message
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Apr 20, 2023
1 parent 7529d87 commit 395840c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ function initSearch(rawSearchIndex) {
: results.query.elems[0].name;
output += "<h3 class=\"search-corrections\">" +
`Type "${orig}" not found. ` +
"Showing results for " +
"Showing results for closest type name " +
`"${results.query.correction}" instead.</h3>`;
}

Expand Down
8 changes: 5 additions & 3 deletions tests/rustdoc-gui/search-corrections.goml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore-tidy-linelength

// Checks that the search tab result tell the user about corrections
// First, try a search-by-name
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
Expand All @@ -22,7 +24,7 @@ assert-css: (".search-corrections", {
})
assert-text: (
".search-corrections",
"Type \"notablestructwithlongnamr\" not found. Showing results for \"notablestructwithlongname\" instead."
"Type \"notablestructwithlongnamr\" not found. Showing results for closest type name \"notablestructwithlongname\" instead."
)

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

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

0 comments on commit 395840c

Please sign in to comment.