Skip to content

Commit e4673ca

Browse files
committed
js: rustdoc.Results has a max_dist field
1 parent 42245d3 commit e4673ca

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/librustdoc/html/static/js/rustdoc.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ declare namespace rustdoc {
237237
query: ParsedQuery,
238238
}
239239

240-
type Results = Map<String, ResultObject>;
240+
type Results = { max_dist?: number } & Map<String, ResultObject>
241241

242242
/**
243243
* An annotated `Row`, used in the viewmodel.

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,7 +2521,11 @@ class DocSearch {
25212521
* @return {Promise<rustdoc.ResultsTable>}
25222522
*/
25232523
async execQuery(origParsedQuery, filterCrates, currentCrate) {
2524-
const results_others = new Map(), results_in_args = new Map(),
2524+
/** @type {rustdoc.Results} */
2525+
const results_others = new Map(),
2526+
/** @type {rustdoc.Results} */
2527+
results_in_args = new Map(),
2528+
/** @type {rustdoc.Results} */
25252529
results_returned = new Map();
25262530

25272531
/** @type {rustdoc.ParsedQuery<rustdoc.QueryElement>} */
@@ -4452,7 +4456,6 @@ class DocSearch {
44524456
return;
44534457
}
44544458

4455-
// @ts-expect-error
44564459
results.max_dist = Math.max(results.max_dist || 0, tfpDist);
44574460
addIntoResults(results, row.id.toString(), pos, 0, tfpDist, 0, Number.MAX_VALUE);
44584461
}
@@ -4561,29 +4564,23 @@ class DocSearch {
45614564
const returned = row.type && row.type.output
45624565
&& checkIfInList(row.type.output, elem, row.type.where_clause, null, 0);
45634566
if (in_args) {
4564-
// @ts-expect-error
45654567
results_in_args.max_dist = Math.max(
4566-
// @ts-expect-error
45674568
results_in_args.max_dist || 0,
45684569
tfpDist,
45694570
);
45704571
const maxDist = results_in_args.size < MAX_RESULTS ?
45714572
(tfpDist + 1) :
4572-
// @ts-expect-error
45734573
results_in_args.max_dist;
45744574
// @ts-expect-error
45754575
addIntoResults(results_in_args, row.id, i, -1, tfpDist, 0, maxDist);
45764576
}
45774577
if (returned) {
4578-
// @ts-expect-error
45794578
results_returned.max_dist = Math.max(
4580-
// @ts-expect-error
45814579
results_returned.max_dist || 0,
45824580
tfpDist,
45834581
);
45844582
const maxDist = results_returned.size < MAX_RESULTS ?
45854583
(tfpDist + 1) :
4586-
// @ts-expect-error
45874584
results_returned.max_dist;
45884585
// @ts-expect-error
45894586
addIntoResults(results_returned, row.id, i, -1, tfpDist, 0, maxDist);

0 commit comments

Comments
 (0)