Change:
Reproduction: Go to Click the gear next to the search field, enable "Directly go to item in search if there is only one result" Refresh page to ensure it's enabled (was required the first time I tried to reproduce, but seemed to work straight away the second time) Search for You should be taken straight to Press "Back" in your browser I expected this to happen: Go back to Instead, this happened: Goes back to then instantly redirects forward again
Taking a look.
Fixed in

Discussion:
searchState.mouseMovedAfterSearch = false; document.title = searchState.title; }, <del> hideResults: () => { switchDisplayedElement(null); </del> <ins> removeQueryParameters: () => { // We change the document title. </ins> document.title = searchState.titleBeforeSearch; <del> // We also remove the query parameter from the URL. </del> if (browserSupportsHistoryApi()) { history.replaceState(null, "", getNakedUrl() + window.location.hash); } }, <ins> hideResults: () => { switchDisplayedElement(null); // We also remove the query parameter from the URL. searchState.removeQueryParameters(); }, </ins> getQueryStringParams: () => { const params = {}; window.location.search.substring(1).split("&").

if (go_to_first || (results.others.length === 1 && getSettingValue("go-to-only-result") === "true") ) { <ins> // Needed to force re-execution of JS when coming back to a page. Let's take this // scenario as example: // // 1. You have the "Directly go to item in search if there is only one result" option //    enabled. // 2. You make a search which results only one result, leading you automatically to //    this result. // 3. You go back to previous page. // // Now, without the call below, the JS will not be re-executed and the previous state // will be used, starting search again since the search input is not empty, leading you // back to the previous page again. window.onunload = () => {}; searchState.removeQueryParameters(); </ins> const elem = document.createElement("a"); elem.href = results.others[0].href; removeClass(elem, "active");

printTab(currentTab); } <ins> function updateSearchHistory(url) { if (!browserSupportsHistoryApi()) { return; } const params = searchState.getQueryStringParams(); if (!history.state && !params.search) { history.pushState(null, "", url); } else { history.replaceState(null, "", url); } } </ins> /** * Perform a search based on the current state of the search input element * and display the results.

if (e) { e.preventDefault(); } const query = parseQuery(searchState.input.value.trim()); let filterCrates = getFilterCrates();

// Because searching is incremental by character, only the most // recent search query is added to the browser history. <del> if (browserSupportsHistoryApi()) { const newURL = buildUrl(query.original, filterCrates); if (!history.state && !params.search) { history.pushState(null, "", newURL); } else { history.replaceState(null, "", newURL); } } </del> <ins> updateSearchHistory(buildUrl(query.original, filterCrates)); </ins> showResults( execQuery(query, searchWords, filterCrates, window.currentCrate),

function updateCrate(ev) { if (ev.target.value === "all crates") { // If we don't remove it from the URL, it'll be picked up again by the search. <del> const params = searchState.getQueryStringParams(); </del> const query = searchState.input.value.trim(); <del> if (!history.state && !params.search) { history.pushState(null, "", buildUrl(query, null)); } else { history.replaceState(null, "", buildUrl(query, null)); } </del> <ins> updateSearchHistory(buildUrl(query, null)); </ins> } // In case you "cut" the entry from the search input, then change the crate filter // before paste back the previous search, you get the old search results without

// We enter it into the search. write: (".search-input", "HasALongTraitWithParams") wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"} <del> assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) </del> <ins> assert-window-property: ({"location": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH) // Regression test for <https://github.com/rust-lang/rust/issues/112676>. // If "go-to-only-result" is enabled and you go back to history, it should not lead you back to the // page result again automatically. history-go-back: wait-for-document-property: {"title": "lib2 - Rust"} assert-window-property: ({"location": "/lib2/index.html"}, ENDS_WITH) </ins> // We try again to see if it goes to the only result go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"