Skip to content

Commit

Permalink
Sync with upstream rust-lang#126176
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed Jun 10, 2024
1 parent ad50c10 commit 0b8ae16
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/librustdoc/html/static/js/search-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3134,15 +3134,19 @@ class DocSearch {
* @param {boolean} isAssocType
*/
const convertNameToId = (elem, isAssocType) => {
if (this.typeNameIdMap.has(elem.normalizedPathLast) &&
(isAssocType || !this.typeNameIdMap.get(elem.normalizedPathLast).assocOnly)) {
elem.id = this.typeNameIdMap.get(elem.normalizedPathLast).id;
const loweredName = elem.pathLast.toLowerCase();
if (typeNameIdMap.has(loweredName) &&
(isAssocType || !typeNameIdMap.get(loweredName).assocOnly)) {
elem.id = typeNameIdMap.get(loweredName).id;
} else if (!parsedQuery.literalSearch) {
let match = null;
let matchDist = maxEditDistance + 1;
let matchName = "";
for (const [name, { id, assocOnly }] of this.typeNameIdMap) {
const dist = editDistance(name, elem.normalizedPathLast, maxEditDistance);
const dist = Math.min(
editDistance(name, loweredName, maxEditDistance),
editDistance(name, elem.normalizedPathLast, maxEditDistance),
);
if (dist <= matchDist && dist <= maxEditDistance &&
(isAssocType || !assocOnly)) {
if (dist === matchDist && matchName > name) {
Expand Down

0 comments on commit 0b8ae16

Please sign in to comment.