File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 484
484
}
485
485
486
486
var patt = new RegExp ( this . _scapeString ( term . toLowerCase ( ) ) ) ;
487
+ var matchedStartsWith = [ ] ;
488
+ var matchedContains = [ ] ;
487
489
var matched = [ ] ;
488
490
var candidates = this . localCandidates ;
489
491
var noSuggestInactive = Boolean ( this . noSuggestInactive ) ;
493
495
var candidate = candidates [ i ] ;
494
496
if ( noSuggestInactive ) {
495
497
if ( ! Boolean ( candidate . inactive ) ) {
498
+ if ( candidate . text . toLowerCase ( ) . startsWith ( term . toLowerCase ( ) ) ) {
499
+ matchedStartsWith . push ( candidate ) ;
500
+ }
501
+
496
502
if ( patt . test ( candidate . text . toLowerCase ( ) ) == true ) {
497
- matched . push ( candidate ) ;
503
+ matchedContains . push ( candidate ) ;
498
504
}
499
505
}
500
506
} else {
507
+ if ( candidate . text . toLowerCase ( ) . startsWith ( term . toLowerCase ( ) ) ) {
508
+ matchedStartsWith . push ( candidate ) ;
509
+ }
510
+
501
511
if ( patt . test ( candidate . text . toLowerCase ( ) ) == true ) {
502
- matched . push ( candidate ) ;
512
+ matchedContains . push ( candidate ) ;
503
513
}
504
514
}
505
515
}
516
+
517
+ matched = matchedStartsWith . concat ( matchedContains ) . filter ( function ( item , pos , self ) {
518
+ return self . indexOf ( item ) == pos ;
519
+ } ) ;
506
520
}
507
521
508
522
if ( typeof ( this . _prefetchedCandidates ) !== 'undefined' ) {
You can’t perform that action at this time.
0 commit comments