rustdoc: search result ranking fix

This commit is contained in:
Michael Howell 2022-05-09 11:46:24 -07:00
parent 0e345b76a5
commit 360d6e4b7d
3 changed files with 24 additions and 1 deletions

View File

@ -1323,7 +1323,6 @@ window.initSearch = rawSearchIndex => {
}
}
lev = levenshtein(searchWord, elem.pathLast);
lev += lev_add;
if (lev > 0 && elem.pathLast.length > 2 && searchWord.indexOf(elem.pathLast) > -1)
{
if (elem.pathLast.length < 6) {
@ -1332,6 +1331,7 @@ window.initSearch = rawSearchIndex => {
lev = 0;
}
}
lev += lev_add;
if (lev > MAX_LEV_DISTANCE) {
return;
} else if (index !== -1 && elem.fullPath.length < 2) {

View File

@ -0,0 +1,14 @@
// exact-check
const QUERY = 'b::ccccccc';
const EXPECTED = {
'others': [
// `ccccccc` is an exact match for all three of these.
// However `b` is a closer match for `bb` than for any
// of the others, so it ought to go first.
{ 'path': 'path_ordering::bb', 'name': 'Ccccccc' },
{ 'path': 'path_ordering::aa', 'name': 'Ccccccc' },
{ 'path': 'path_ordering::dd', 'name': 'Ccccccc' },
],
};

View File

@ -0,0 +1,9 @@
pub mod dd {
pub struct Ccccccc;
}
pub mod aa {
pub struct Ccccccc;
}
pub mod bb {
pub struct Ccccccc;
}