From 09787b5b02c43eff07c949d85bca8e7a0923666d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 2 Jan 2019 18:33:55 +0100 Subject: [PATCH] doxygen: don't try to go to the result if there isn't any. --- doxygen/search.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/doxygen/search.js b/doxygen/search.js index d0b9f7f6..901593ed 100644 --- a/doxygen/search.js +++ b/doxygen/search.js @@ -545,6 +545,7 @@ var Search = { /* Nothing found */ } else { + document.getElementById('search-results').innerHTML = ''; document.getElementById('search-results').style.display = 'none'; document.getElementById('search-notfound').style.display = 'block'; } @@ -680,14 +681,18 @@ if(typeof document !== 'undefined') { } return false; /* so the keypress doesn't affect input cursor */ - /* Go to result */ + /* Go to result (if any) */ } else if(event.key == 'Enter') { - document.getElementById('search-current').firstElementChild.click(); + let result = document.getElementById('search-current'); + if(result) { + result.firstElementChild.click(); + + /* We might be staying on the same page, so restore scrollbar, + and prevent page layout jumps */ + document.body.style.overflow = 'auto'; + document.body.style.paddingRight = '0'; + } - /* We might be staying on the same page, so restore scrollbar, - and prevent page layout jumps */ - document.body.style.overflow = 'auto'; - document.body.style.paddingRight = '0'; return false; /* so the form doesn't get sent */ /* Looks like the user is inserting some text (and not cutting, -- 2.30.2