about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-04-21 15:07:52 -0700
committerMichael Howell <michael@notriddle.com>2023-04-21 15:09:09 -0700
commit0cd387415558729c72962bf8f47d229f0b93ce50 (patch)
tree1ec3063913e27f063bfc65027e671fd52115ce3b
parent9d69ee0574b2d315d692af1ad94c211a448101eb (diff)
downloadrust-0cd387415558729c72962bf8f47d229f0b93ce50.tar.gz
rust-0cd387415558729c72962bf8f47d229f0b93ce50.zip
rustdoc: clean up redundant search hiding results code
  * There's no need to call `history.replaceState` right before
    calling `searchState.hideResults`, which already does it.
  * There's no need to implement hiding search results when that
    is already implemented.
-rw-r--r--src/librustdoc/html/static/js/main.js5
-rw-r--r--src/librustdoc/html/static/js/search.js4
2 files changed, 1 insertions, 8 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index b1c6eaee70d..bccf675c14b 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -375,10 +375,7 @@ function preLoadCss(cssUrl) {
 
     function handleEscape(ev) {
         searchState.clearInputTimeout();
-        switchDisplayedElement(null);
-        if (browserSupportsHistoryApi()) {
-            history.replaceState(null, "", getNakedUrl() + window.location.hash);
-        }
+        searchState.hideResults();
         ev.preventDefault();
         searchState.defocus();
         window.hideAllModals(true); // true = reset focus for tooltips
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 929dae81c8d..3dc4f2149b8 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -2412,10 +2412,6 @@ function initSearch(rawSearchIndex) {
         const searchAfter500ms = () => {
             searchState.clearInputTimeout();
             if (searchState.input.value.length === 0) {
-                if (browserSupportsHistoryApi()) {
-                    history.replaceState(null, window.currentCrate + " - Rust",
-                        getNakedUrl() + window.location.hash);
-                }
                 searchState.hideResults();
             } else {
                 searchState.timeout = setTimeout(search, 500);