rustdoc: search result ranking fix
This commit is contained in:
parent
0e345b76a5
commit
360d6e4b7d
3 changed files with 24 additions and 1 deletions
|
@ -1323,7 +1323,6 @@ window.initSearch = rawSearchIndex => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lev = levenshtein(searchWord, elem.pathLast);
|
lev = levenshtein(searchWord, elem.pathLast);
|
||||||
lev += lev_add;
|
|
||||||
if (lev > 0 && elem.pathLast.length > 2 && searchWord.indexOf(elem.pathLast) > -1)
|
if (lev > 0 && elem.pathLast.length > 2 && searchWord.indexOf(elem.pathLast) > -1)
|
||||||
{
|
{
|
||||||
if (elem.pathLast.length < 6) {
|
if (elem.pathLast.length < 6) {
|
||||||
|
@ -1332,6 +1331,7 @@ window.initSearch = rawSearchIndex => {
|
||||||
lev = 0;
|
lev = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lev += lev_add;
|
||||||
if (lev > MAX_LEV_DISTANCE) {
|
if (lev > MAX_LEV_DISTANCE) {
|
||||||
return;
|
return;
|
||||||
} else if (index !== -1 && elem.fullPath.length < 2) {
|
} else if (index !== -1 && elem.fullPath.length < 2) {
|
||||||
|
|
14
src/test/rustdoc-js/path-ordering.js
Normal file
14
src/test/rustdoc-js/path-ordering.js
Normal 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' },
|
||||||
|
],
|
||||||
|
};
|
9
src/test/rustdoc-js/path-ordering.rs
Normal file
9
src/test/rustdoc-js/path-ordering.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
pub mod dd {
|
||||||
|
pub struct Ccccccc;
|
||||||
|
}
|
||||||
|
pub mod aa {
|
||||||
|
pub struct Ccccccc;
|
||||||
|
}
|
||||||
|
pub mod bb {
|
||||||
|
pub struct Ccccccc;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue