|
50 | 50 | const domSectTypes = document.getElementById("sectTypes"); |
51 | 51 | const domSectValues = document.getElementById("sectValues"); |
52 | 52 | const domSourceText = document.getElementById("sourceText"); |
| 53 | + const domSourceLineNumbers = document.getElementById("sourceLineNumbers"); |
53 | 54 | const domStatus = document.getElementById("status"); |
54 | 55 | const domTableFnErrors = document.getElementById("tableFnErrors"); |
55 | 56 | const domTldDocs = document.getElementById("tldDocs"); |
|
129 | 130 | domSearch.addEventListener('input', onSearchChange, false); |
130 | 131 | window.addEventListener('keydown', onWindowKeyDown, false); |
131 | 132 | onHashChange(null); |
| 133 | + if (domSearch.value) { |
| 134 | + // user started typing a search query while the page was loading |
| 135 | + curSearchIndex = -1; |
| 136 | + startAsyncSearch(); |
| 137 | + } |
132 | 138 | }); |
133 | 139 | }); |
134 | 140 |
|
|
233 | 239 | href: location.hash, |
234 | 240 | }]); |
235 | 241 |
|
| 242 | + domSourceLineNumbers.innerHTML = declLineNumbersHtml(decl_index); |
236 | 243 | domSourceText.innerHTML = declSourceHtml(decl_index); |
237 | 244 |
|
238 | 245 | domSectSource.classList.remove("hidden"); |
|
384 | 391 | if (members.length !== 0 || fields.length !== 0) { |
385 | 392 | renderNamespace(decl_index, members, fields); |
386 | 393 | } else { |
| 394 | + domSourceLineNumbers.innerHTML = declLineNumbersHtml(decl_index); |
387 | 395 | domSourceText.innerHTML = declSourceHtml(decl_index); |
388 | 396 | domSectSource.classList.remove("hidden"); |
389 | 397 | } |
|
414 | 422 | renderErrorSet(base_decl, errorSetNodeList(decl_index, errorSetNode)); |
415 | 423 | } |
416 | 424 |
|
| 425 | + domSourceLineNumbers.innerHTML = declLineNumbersHtml(decl_index); |
417 | 426 | domSourceText.innerHTML = declSourceHtml(decl_index); |
418 | 427 | domSectSource.classList.remove("hidden"); |
419 | 428 | } |
|
428 | 437 | domTldDocs.classList.remove("hidden"); |
429 | 438 | } |
430 | 439 |
|
| 440 | + domSourceLineNumbers.innerHTML = declLineNumbersHtml(decl_index); |
431 | 441 | domSourceText.innerHTML = declSourceHtml(decl_index); |
432 | 442 | domSectSource.classList.remove("hidden"); |
433 | 443 | } |
|
643 | 653 | } |
644 | 654 |
|
645 | 655 | function onHashChange(state) { |
| 656 | + // Use a non-null state value to prevent the window scrolling if the user goes back to this history entry. |
646 | 657 | history.replaceState({}, ""); |
647 | 658 | navigate(location.hash); |
648 | 659 | if (state == null) window.scrollTo({top: 0}); |
649 | 660 | } |
650 | 661 |
|
651 | 662 | function onPopState(ev) { |
652 | 663 | onHashChange(ev.state); |
| 664 | + syncDomSearch(); |
653 | 665 | } |
654 | 666 |
|
655 | 667 | function navigate(location_hash) { |
656 | 668 | updateCurNav(location_hash); |
657 | | - if (domSearch.value !== curNavSearch) { |
658 | | - domSearch.value = curNavSearch; |
659 | | - } |
660 | 669 | render(); |
661 | 670 | if (imFeelingLucky) { |
662 | 671 | imFeelingLucky = false; |
663 | 672 | activateSelectedResult(); |
664 | 673 | } |
665 | 674 | } |
666 | 675 |
|
| 676 | + function syncDomSearch() { |
| 677 | + if (domSearch.value !== curNavSearch) { |
| 678 | + domSearch.value = curNavSearch; |
| 679 | + } |
| 680 | + } |
| 681 | + |
667 | 682 | function activateSelectedResult() { |
668 | 683 | if (domSectSearchResults.classList.contains("hidden")) { |
669 | 684 | return; |
|
908 | 923 | return unwrapString(wasm_exports.decl_source_html(decl_index)); |
909 | 924 | } |
910 | 925 |
|
| 926 | + function declLineNumbersHtml(decl_index) { |
| 927 | + return unwrapString(wasm_exports.decl_line_numbers_html(decl_index)); |
| 928 | + } |
| 929 | + |
911 | 930 | function declDoctestHtml(decl_index) { |
912 | 931 | return unwrapString(wasm_exports.decl_doctest_html(decl_index)); |
913 | 932 | } |
|
0 commit comments