Skip to content

Commit 0e4c829

Browse files
Add "As parameters" items as well
1 parent 5c5ab0d commit 0e4c829

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/librustdoc/html/static/main.js

+25-22
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@
564564
var results_length = 0;
565565
val = extractGenerics(val.substr(1, val.length - 2));
566566
for (var i = 0; i < nSearchWords; ++i) {
567-
var param = findArg(searchIndex[i], val, true);
567+
var in_args = findArg(searchIndex[i], val, true);
568568
var returned = checkReturned(searchIndex[i], val, true);
569569
var ty = searchIndex[i];
570570
if (searchWords[i] === val.name) {
@@ -575,20 +575,20 @@
575575
results[ty.path + ty.name] = {id: i, index: -1};
576576
results_length += 1;
577577
}
578-
} else if ((param === true || returned === true) &&
578+
} else if ((in_args === true || returned === true) &&
579579
typePassesFilter(typeFilter, searchIndex[i].ty)) {
580580
if (results[ty.path + ty.name] === undefined) {
581581
results[ty.path + ty.name] = {
582582
id: i,
583583
index: -1,
584584
dontValidate: true,
585-
param: param,
585+
in_args: in_args,
586586
returned: returned,
587587
};
588588
results_length += 1;
589589
} else {
590-
if (param === true) {
591-
results[ty.path + ty.name].param = true;
590+
if (in_args === true) {
591+
results[ty.path + ty.name].in_args = true;
592592
}
593593
if (returned === true) {
594594
results[ty.path + ty.name].returned = true;
@@ -625,7 +625,7 @@
625625
var typeOutput = type.output ? type.output.name : "";
626626
var returned = checkReturned(ty, output, true);
627627
if (output.name === "*" || returned === true) {
628-
var param = false;
628+
var in_args = false;
629629
var module = false;
630630

631631
if (input === "*") {
@@ -635,23 +635,23 @@
635635
for (var it = 0; allFound === true && it < inputs.length; it++) {
636636
allFound = checkType(type, inputs[it], true);
637637
}
638-
param = allFound;
638+
in_args = allFound;
639639
}
640-
if (param === true || returned === true || module === true) {
640+
if (in_args === true || returned === true || module === true) {
641641
if (results[ty.path + ty.name] !== undefined) {
642642
if (returned === true) {
643643
results[ty.path + ty.name].returned = true;
644644
}
645-
if (param === true) {
646-
results[ty.path + ty.name].param = true;
645+
if (in_args === true) {
646+
results[ty.path + ty.name].in_args = true;
647647
}
648648
} else {
649649
results[ty.path + ty.name] = {
650650
id: i,
651651
index: -1,
652652
dontValidate: true,
653653
returned: returned,
654-
param: param,
654+
in_args: in_args,
655655
};
656656
}
657657
}
@@ -677,10 +677,10 @@
677677
continue;
678678
}
679679
var returned = false;
680-
var param = false;
680+
var in_args = false;
681681
var index = -1;
682682
// we want lev results to go lower than others
683-
var lev = 0;
683+
var lev = MAX_LEV_DISTANCE;
684684

685685
if (searchWords[j].indexOf(split[i]) > -1 ||
686686
searchWords[j].indexOf(val) > -1 ||
@@ -696,7 +696,7 @@
696696
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
697697
(results[ty.path + ty.name] === undefined ||
698698
results[ty.path + ty.name].lev > lev_distance)) {
699-
lev = lev_distance;
699+
lev = min(lev, lev_distance);
700700
index = 0;
701701
}
702702
}
@@ -705,8 +705,8 @@
705705
if (typePassesFilter(typeFilter, searchIndex[j].ty) &&
706706
(results[ty.path + ty.name] === undefined ||
707707
results[ty.path + ty.name].lev > lev_distance)) {
708-
param = true;
709-
lev = lev_distance;
708+
in_args = true;
709+
lev = min(lev_distance, lev);
710710
index = 0;
711711
}
712712
}
@@ -716,7 +716,7 @@
716716
(results[ty.path + ty.name] === undefined ||
717717
results[ty.path + ty.name].lev > lev_distance)) {
718718
returned = true;
719-
lev = lev_distance;
719+
lev = min(lev_distance, lev);
720720
index = 0;
721721
}
722722
}
@@ -726,16 +726,16 @@
726726
id: j,
727727
index: index,
728728
lev: lev,
729-
param: param,
729+
in_args: in_args,
730730
returned: returned,
731731
};
732732
results_length += 1;
733733
} else {
734734
if (results[ty.path + ty.name].lev > lev) {
735735
results[ty.path + ty.name].lev = lev;
736736
}
737-
if (param === true) {
738-
results[ty.path + ty.name].param = true;
737+
if (in_args === true) {
738+
results[ty.path + ty.name].in_args = true;
739739
}
740740
if (returned === true) {
741741
results[ty.path + ty.name].returned = true;
@@ -1164,11 +1164,14 @@
11641164
filterdata.push([obj.name, obj.ty, obj.path, obj.desc]);
11651165
if (obj.type) {
11661166
if (results['returned'].length < maxResults &&
1167-
resultIndex[i].returned === true) {
1167+
resultIndex[i].returned === true)
1168+
{
11681169
results['returned'].push(obj);
11691170
added = true;
11701171
}
1171-
if (results['in_args'].length < maxResults && resultIndex[i] === true) {
1172+
if (results['in_args'].length < maxResults &&
1173+
resultIndex[i].in_args === true)
1174+
{
11721175
results['in_args'].push(obj);
11731176
added = true;
11741177
}

0 commit comments

Comments
 (0)