@@ -900,11 +900,12 @@ define(function (require, exports, module) {
900900 }
901901 let totalResultCount = orderedResults . length ;
902902 function _mergeResults ( resultArray ) {
903- for ( let result of resultArray ) {
903+ for ( let resultItem of resultArray ) {
904904 if ( maxResults && totalResultCount >= maxResults ) {
905905 break ;
906906 }
907- orderedResults . push ( result ) ;
907+ orderedResults . push ( resultItem ) ;
908+ totalResultCount ++ ;
908909 }
909910 }
910911
@@ -1086,7 +1087,7 @@ define(function (require, exports, module) {
10861087 *
10871088 * @param {string } query - The search query to match against choices.
10881089 * @param {Array<string> } choices - The list of possible code hints.
1089- * @param {object } options - An optional object to specify additional search options.
1090+ * @param {object } [ options] - An optional object to specify additional search options.
10901091 * @param {number } options.limit - Maximum number of results to return
10911092 * @param {Array<string> } options.boostPrefixList -Optional, Will rank matching items in the choices to top
10921093 * if query starts with the array. EG: on typing b, we have to show background-color
@@ -1099,17 +1100,24 @@ define(function (require, exports, module) {
10991100 function codeHintsSort ( query , choices , options ) {
11001101 let choice ;
11011102 let results = [ ] ;
1103+ options = options || { } ;
11021104 for ( let i = 0 ; i < choices . length ; i ++ ) {
11031105 choice = choices [ i ] ;
11041106 const result = stringMatch ( choice , query , codeHintsMatcherOptions ) ;
11051107 if ( result ) {
11061108 result . sourceIndex = i ;
1109+ if ( ! query ) {
1110+ delete result . stringRanges ; // for empty query like "", we dont want to show any string ranges
1111+ }
11071112 results . push ( result ) ;
11081113 }
11091114 }
11101115 basicMatchSort ( results ) ;
11111116 results = _codeHintsRelevanceSort ( results , query , options . boostPrefixList || [ ] ,
11121117 options . limit , options . onlyContiguous ) ;
1118+ if ( ! query ) {
1119+ return results ;
1120+ }
11131121 for ( let result of results ) {
11141122 const ranges = _computeMatchingRanges ( query , result . label ) ;
11151123 if ( ranges ) {
0 commit comments