| ... | ... | @@ -280,10 +280,10 @@ |
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | typesList.sort(function(a, b) { |
| 283 | | return operatorCompare(a.name.toLowerCase(), b.name.toLowerCase()); |
| 283 | return operatorCompare(a.name, b.name); |
| 284 | 284 | }); |
| 285 | 285 | fnsList.sort(function(a, b) { |
| 286 | | return operatorCompare(a.name.toLowerCase(), b.name.toLowerCase()); |
| 286 | return operatorCompare(a.name, b.name); |
| 287 | 287 | }); |
| 288 | 288 | |
| 289 | 289 | if (typesList.length !== 0) { |
| ... | ... | @@ -488,11 +488,9 @@ |
| 488 | 488 | function onSearchKeyDown(ev) { |
| 489 | 489 | switch (ev.which) { |
| 490 | 490 | case 13: |
| 491 | | var liDom = null; |
| 492 | | if (domListSearchResults.children.length === 1) { |
| 491 | var liDom = domListSearchResults.children[curSearchIndex]; |
| 492 | if (liDom == null && domListSearchResults.children.length !== 0) { |
| 493 | 493 | liDom = domListSearchResults.children[0]; |
| 494 | | } else { |
| 495 | | liDom = domListSearchResults.children[curSearchIndex]; |
| 496 | 494 | } |
| 497 | 495 | if (liDom != null) { |
| 498 | 496 | var aDom = liDom.children[0]; |
| ... | ... | @@ -604,29 +602,49 @@ |
| 604 | 602 | |
| 605 | 603 | var decl = zigAnalysis.decls[declIndex]; |
| 606 | 604 | var lastPkgName = canonPath.pkgNames[canonPath.pkgNames.length - 1]; |
| 607 | | var searchText = lastPkgName + "." + canonPath.declNames.join('.'); |
| 605 | var fullPathSearchText = lastPkgName + "." + canonPath.declNames.join('.'); |
| 608 | 606 | var astNode = zigAnalysis.astNodes[decl.src]; |
| 607 | var fileAndDocs = zigAnalysis.files[astNode.file]; |
| 609 | 608 | if (astNode.docs != null) { |
| 610 | | searchText += "\n" + astNode.docs; |
| 609 | fileAndDocs += "\n" + astNode.docs; |
| 611 | 610 | } |
| 612 | | var file = zigAnalysis.files[astNode.file]; |
| 613 | | searchText += "\n" + file; |
| 611 | var fullPathSearchTextLower = fullPathSearchText; |
| 614 | 612 | if (ignoreCase) { |
| 615 | | searchText = searchText.toLowerCase(); |
| 613 | fullPathSearchTextLower = fullPathSearchTextLower.toLowerCase(); |
| 614 | fileAndDocs = fileAndDocs.toLowerCase(); |
| 616 | 615 | } |
| 617 | 616 | |
| 617 | var points = 0; |
| 618 | 618 | for (var termIndex = 0; termIndex < terms.length; termIndex += 1) { |
| 619 | 619 | var term = terms[termIndex]; |
| 620 | | if (searchText.indexOf(term) >= 0) { |
| 620 | |
| 621 | // exact, case sensitive match of full decl path |
| 622 | if (fullPathSearchText === term) { |
| 623 | points += 4; |
| 624 | continue; |
| 625 | } |
| 626 | // exact, case sensitive match of just decl name |
| 627 | if (decl.name == term) { |
| 628 | points += 3; |
| 629 | continue; |
| 630 | } |
| 631 | // substring, case insensitive match of full decl path |
| 632 | if (fullPathSearchTextLower.indexOf(term) >= 0) { |
| 633 | points += 2; |
| 621 | 634 | continue; |
| 622 | | } else { |
| 623 | | continue decl_loop; |
| 624 | 635 | } |
| 636 | if (fileAndDocs.indexOf(term) >= 0) { |
| 637 | points += 1; |
| 638 | continue; |
| 639 | } |
| 640 | |
| 641 | continue decl_loop; |
| 625 | 642 | } |
| 626 | 643 | |
| 627 | 644 | matchedItems.push({ |
| 628 | 645 | decl: decl, |
| 629 | 646 | path: canonPath, |
| 647 | points: points, |
| 630 | 648 | }); |
| 631 | 649 | } |
| 632 | 650 | |
| ... | ... | @@ -634,6 +652,8 @@ |
| 634 | 652 | resizeDomList(domListSearchResults, matchedItems.length, '<li><a href="#"></a></li>'); |
| 635 | 653 | |
| 636 | 654 | matchedItems.sort(function(a, b) { |
| 655 | var cmp = operatorCompare(b.points, a.points); |
| 656 | if (cmp != 0) return cmp; |
| 637 | 657 | return operatorCompare(a.decl.name, b.decl.name); |
| 638 | 658 | }); |
| 639 | 659 | |