chiark / gitweb /
doxygen: don't try to go to the result if there isn't any.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 2 Jan 2019 17:33:55 +0000 (18:33 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Wed, 2 Jan 2019 21:07:36 +0000 (22:07 +0100)
doxygen/search.js

index d0b9f7f605b66856b616de45d69fcaa2c9fbc732..901593edf4fc3a9f2d49ae3cb721847d91855737 100644 (file)
@@ -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,