Skip to content

Commit

Permalink
Add source code query event
Browse files Browse the repository at this point in the history
  • Loading branch information
Folyd committed Jun 7, 2024
1 parent d9d4d02 commit 4b679bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core
14 changes: 14 additions & 0 deletions extension/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <match>${query}</match> on ${isOfflineMode ? "offline mode" : stdSearcher.getRootPath()}`,
}];
},
});

// Nightly std docs search
omnibox.addPrefixQueryEvent("/", {
name: "Nightly docs",
Expand Down

0 comments on commit 4b679bd

Please sign in to comment.