From 05299fbe46d7e58bdd22fe9bf71ce11fc0cc39cf Mon Sep 17 00:00:00 2001 From: mat Date: Sat, 23 Dec 2023 02:10:17 -0600 Subject: [PATCH] fix docs_rs when there is no doc but there is an item decl --- src/engines/postsearch/docs_rs.rs | 7 +++++-- src/web/assets/script.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/engines/postsearch/docs_rs.rs b/src/engines/postsearch/docs_rs.rs index c5d509e..cc1df32 100644 --- a/src/engines/postsearch/docs_rs.rs +++ b/src/engines/postsearch/docs_rs.rs @@ -35,9 +35,12 @@ pub fn parse_response(body: &str, url: Url) -> Option { let doc_query = Selector::parse(".docblock").unwrap(); - let doc = dom.select(&doc_query).next()?; + let doc_html = dom + .select(&doc_query) + .next() + .map(|doc| doc.inner_html()) + .unwrap_or_default(); - let doc_html = doc.inner_html(); let item_decl = dom .select(&Selector::parse(".item-decl").unwrap()) .next() diff --git a/src/web/assets/script.js b/src/web/assets/script.js index e355837..5156ebb 100644 --- a/src/web/assets/script.js +++ b/src/web/assets/script.js @@ -147,7 +147,7 @@ searchInputEl.addEventListener("input", () => { clearFocusedSuggestion(); updateSuggestions(); }); -// and on focus +// and when they click suggestions searchInputEl.addEventListener("click", updateSuggestions); // on unfocus hide the suggestions searchInputEl.addEventListener("blur", (e) => {