From 4b679bd1bce34c93b5fe9a69ae95e5fe535dbc73 Mon Sep 17 00:00:00 2001 From: Folyd Date: Thu, 6 Jun 2024 23:47:16 -0700 Subject: [PATCH] Add source code query event --- core | 2 +- extension/main.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core b/core index 88a20de0..1a9d7d1b 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 88a20de012b14883138aeae46beb58941c476b85 +Subproject commit 1a9d7d1b474751652ed5cc124a51bb266c269608 diff --git a/extension/main.js b/extension/main.js index 4be00982..2db3897b 100644 --- a/extension/main.js +++ b/extension/main.js @@ -164,6 +164,20 @@ async function start(omnibox) { }, }); + omnibox.addRegexQueryEvent(/^s(?:rc)?:/i, { + name: "Source code", + onSearch: (query) => { + return stdSearcher.search(query); + }, + onFormat: formatDoc, + onAppend: (query) => { + return [{ + content: stdSearcher.getSearchUrl(query), + description: `Search Rust docs ${query} on ${isOfflineMode ? "offline mode" : stdSearcher.getRootPath()}`, + }]; + }, + }); + // Nightly std docs search omnibox.addPrefixQueryEvent("/", { name: "Nightly docs",