Skip to content

Commit bfd5a26

Browse files
Correctly handle literal search on paths
1 parent be8de5d commit bfd5a26

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,7 +3639,7 @@ class DocSearch {
36393639
if (contains.length === 0) {
36403640
return 0;
36413641
}
3642-
const maxPathEditDistance = Math.floor(
3642+
const maxPathEditDistance = parsedQuery.literalSearch ? 0 : Math.floor(
36433643
contains.reduce((acc, next) => acc + next.length, 0) / 3,
36443644
);
36453645
let ret_dist = maxPathEditDistance + 1;
@@ -3650,7 +3650,9 @@ class DocSearch {
36503650
let dist_total = 0;
36513651
for (let x = 0; x < clength; ++x) {
36523652
const [p, c] = [path[i + x], contains[x]];
3653-
if (Math.floor((p.length - c.length) / 3) <= maxPathEditDistance &&
3653+
if (parsedQuery.literalSearch && p !== c) {
3654+
continue pathiter;
3655+
} else if (Math.floor((p.length - c.length) / 3) <= maxPathEditDistance &&
36543656
p.indexOf(c) !== -1
36553657
) {
36563658
// discount distance on substring match

0 commit comments

Comments
 (0)