Skip to content

Commit 0eceeaf

Browse files
committed
Fix ci check
1 parent 5e52943 commit 0eceeaf

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced
88
if (!Array.prototype.toSpliced) {
99
// Can't use arrow functions, because we want `this`
10-
Array.prototype.toSpliced = function () {
10+
Array.prototype.toSpliced = function() {
1111
const me = this.slice();
1212
Array.prototype.splice.apply(me, arguments);
1313
return me;
@@ -1185,6 +1185,10 @@ class DocSearch {
11851185
this.searchIndex = this.buildIndex(rawSearchIndex);
11861186
}
11871187

1188+
static getItemType(ty) {
1189+
return itemTypes[ty];
1190+
}
1191+
11881192
/**
11891193
* Add an item to the type Name->ID map, or, if one already exists, use it.
11901194
* Returns the number. If name is "" or null, return null (pure generic).
@@ -3135,9 +3139,9 @@ class DocSearch {
31353139
*/
31363140
const convertNameToId = (elem, isAssocType) => {
31373141
const loweredName = elem.pathLast.toLowerCase();
3138-
if (typeNameIdMap.has(loweredName) &&
3139-
(isAssocType || !typeNameIdMap.get(loweredName).assocOnly)) {
3140-
elem.id = typeNameIdMap.get(loweredName).id;
3142+
if (this.typeNameIdMap.has(loweredName) &&
3143+
(isAssocType || !this.typeNameIdMap.get(loweredName).assocOnly)) {
3144+
elem.id = this.typeNameIdMap.get(loweredName).id;
31413145
} else if (!parsedQuery.literalSearch) {
31423146
let match = null;
31433147
let matchDist = maxEditDistance + 1;

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77

88
(function() {
9+
let rawSearchIndex;
10+
let docSearch;
911
const longItemTypes = [
1012
"keyword",
1113
"primitive type",
@@ -143,7 +145,7 @@
143145

144146
for (const item of array) {
145147
const name = item.name;
146-
const type = itemTypes[item.ty];
148+
const type = window.DocSearch.getItemType(item.ty);
147149
const longType = longItemTypes[item.ty];
148150
const typeName = longType.length !== 0 ? `${longType}` : "?";
149151

@@ -247,7 +249,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
247249
return;
248250
}
249251
if (results.query === undefined) {
250-
results.query = DocSearch.parseQuery(searchState.input.value);
252+
results.query = window.DocSearch.parseQuery(searchState.input.value);
251253
}
252254

253255
currentResults = results.query.userQuery;
@@ -378,7 +380,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
378380
* @param {boolean} [forced]
379381
*/
380382
async function search(forced) {
381-
const query = DocSearch.parseQuery(searchState.input.value.trim());
383+
const query = window.DocSearch.parseQuery(searchState.input.value.trim());
382384
let filterCrates = getFilterCrates();
383385

384386
if (!forced && query.userQuery === currentResults) {
@@ -595,8 +597,9 @@ ${item.displayPath}<span class="${type}">${name}</span>\
595597
}
596598

597599
function initSearch(rawSearchIndex) {
600+
rawSearchIndex = rawSearchIndex;
598601
if (typeof window !== "undefined") {
599-
window.docSearch = new window.DocSearch(rawSearchIndex);
602+
docSearch = new window.DocSearch(rawSearchIndex);
600603
} else if (typeof exports !== "undefined") {
601604
exports.docSearch = new exports.DocSearch(rawSearchIndex);
602605
}

0 commit comments

Comments
 (0)