diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-12-26 15:57:27 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2020-12-30 14:47:13 +0100 |
| commit | 33377670773e07cc75a0a28424413ba74fc2bfb8 (patch) | |
| tree | fc613605d13632dad21831c728169869502ea073 /src/librustdoc/html/static | |
| parent | 2acf6ee6d2ab3acf3f4d2117591ac1143c8232fe (diff) | |
| download | rust-33377670773e07cc75a0a28424413ba74fc2bfb8.tar.gz rust-33377670773e07cc75a0a28424413ba74fc2bfb8.zip | |
If the current search result tab is empty, it picks the first non-empty one. If all are empty, the current one doesn't change.
Diffstat (limited to 'src/librustdoc/html/static')
| -rw-r--r-- | src/librustdoc/html/static/main.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 1de4b0016c5..6cecbf6643c 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1664,6 +1664,21 @@ function defocusSearchBar() { var ret_in_args = addTab(results.in_args, query, false); var ret_returned = addTab(results.returned, query, false); + // Navigate to the relevant tab if the current tab is empty, like in case users search + // for "-> String". If they had selected another tab previously, they have to click on + // it again. + if ((currentTab === 0 && ret_others[1] === 0) || + (currentTab === 1 && ret_in_args[1] === 0) || + (currentTab === 2 && ret_returned[1] === 0)) { + if (ret_others[1] !== 0) { + currentTab = 0; + } else if (ret_in_args[1] !== 0) { + currentTab = 1; + } else if (ret_returned[1] !== 0) { + currentTab = 2; + } + } + var output = "<h1>Results for " + escape(query.query) + (query.type ? " (type: " + escape(query.type) + ")" : "") + "</h1>" + "<div id=\"titles\">" + |
