Skip to content

Commit

Permalink
Support both legacy object search index and latest map search index
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed Feb 13, 2024
1 parent 4cca580 commit c214778
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions extension/script/add-search-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,17 @@

// Remove unnecessary std crate's search index, such as core, alloc, etc
let searchIndex = Object.create(null)
STD_CRATES.forEach(crate => {
searchIndex[crate] = window.searchIndex[crate];
});
if (window.searchIndex instanceof Map) {
// [rustdoc] Use Map instead of Object for source files and search index #118910
// https://github.com/rust-lang/rust/pull/118910
STD_CRATES.forEach(crate => {
searchIndex[crate] = window.searchIndex.get(crate);
});
} else {
STD_CRATES.forEach(crate => {
searchIndex[crate] = window.searchIndex[crate];
});
}
window.postMessage({
direction: `rust-search-extension:std`,
message: {
Expand Down

0 comments on commit c214778

Please sign in to comment.