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