From 1ca145778a4971d82c56025ece1824ec672428b9 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Tue, 2 Apr 2024 14:35:25 +0800 Subject: [PATCH] Support type '/' to search --- src/librustdoc/html/static/js/main.js | 3 ++- src/librustdoc/html/templates/page.html | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index b9a769a7c6d..0bd75d4a4fc 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -438,6 +438,7 @@ function preLoadCss(cssUrl) { case "s": case "S": + case "/": ev.preventDefault(); searchState.focus(); break; @@ -1310,7 +1311,7 @@ function preLoadCss(cssUrl) { const shortcuts = [ ["?", "Show this help dialog"], - ["S", "Focus the search field"], + ["S / /", "Focus the search field"], ["↑", "Move up in search results"], ["↓", "Move down in search results"], ["← / →", "Switch result tab (when results focused)"], diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 0f3debae66c..27b0ed69a58 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -135,7 +135,7 @@ aria-label="Run search in the documentation" {#+ #} autocomplete="off" {#+ #} spellcheck="false" {#+ #} - placeholder="Click or press ‘S’ to search, ‘?’ for more options…" {#+ #} + placeholder="Type ‘S’ or ‘/’ to search, ‘?’ for more options…" {#+ #} type="search"> {# #}
{# #} ? {# #}