Skip to content

Commit 38a8a77

Browse files
committed
Sync with upstream rust-lang#126176
1 parent 3f6e257 commit 38a8a77

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: src/librustdoc/html/static/js/search-core.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -3134,15 +3134,19 @@ class DocSearch {
31343134
* @param {boolean} isAssocType
31353135
*/
31363136
const convertNameToId = (elem, isAssocType) => {
3137-
if (this.typeNameIdMap.has(elem.normalizedPathLast) &&
3138-
(isAssocType || !this.typeNameIdMap.get(elem.normalizedPathLast).assocOnly)) {
3139-
elem.id = this.typeNameIdMap.get(elem.normalizedPathLast).id;
3137+
const loweredName = elem.pathLast.toLowerCase();
3138+
if (typeNameIdMap.has(loweredName) &&
3139+
(isAssocType || !typeNameIdMap.get(loweredName).assocOnly)) {
3140+
elem.id = typeNameIdMap.get(loweredName).id;
31403141
} else if (!parsedQuery.literalSearch) {
31413142
let match = null;
31423143
let matchDist = maxEditDistance + 1;
31433144
let matchName = "";
31443145
for (const [name, { id, assocOnly }] of this.typeNameIdMap) {
3145-
const dist = editDistance(name, elem.normalizedPathLast, maxEditDistance);
3146+
const dist = Math.min(
3147+
editDistance(name, loweredName, maxEditDistance),
3148+
editDistance(name, elem.normalizedPathLast, maxEditDistance),
3149+
);
31463150
if (dist <= matchDist && dist <= maxEditDistance &&
31473151
(isAssocType || !assocOnly)) {
31483152
if (dist === matchDist && matchName > name) {

0 commit comments

Comments
 (0)