@@ -65,10 +65,21 @@ export function presetCollection(collection) {
6565 return index === 0 ;
6666 }
6767
68- function sortPresets ( nameProp ) {
68+ function sortPresets ( nameProp , aliasesProp ) {
6969 return function sortNames ( a , b ) {
7070 let aCompare = a [ nameProp ] ( ) ;
7171 let bCompare = b [ nameProp ] ( ) ;
72+ if ( aliasesProp ) {
73+ // also search in aliases
74+ const findMatchingAlias = strings => {
75+ if ( strings . some ( s => s === value ) )
76+ return strings . find ( s => s === value ) ;
77+ else
78+ return strings . find ( s => s . includes ( value ) ) ;
79+ }
80+ aCompare = findMatchingAlias ( [ aCompare ] . concat ( a [ aliasesProp ] ( ) ) ) ;
81+ bCompare = findMatchingAlias ( [ bCompare ] . concat ( b [ aliasesProp ] ( ) ) ) ;
82+ }
7283
7384 // priority if search string matches preset name exactly - #4325
7485 if ( value === aCompare ) return - 1 ;
@@ -99,7 +110,7 @@ export function presetCollection(collection) {
99110 // matches value to preset.name
100111 const leadingNames = searchable
101112 . filter ( a => leading ( a . searchName ( ) ) || a . searchAliases ( ) . some ( leading ) )
102- . sort ( sortPresets ( 'searchName' ) ) ;
113+ . sort ( sortPresets ( 'searchName' , 'searchAliases' ) ) ;
103114
104115 // matches value to preset suggestion name
105116 const leadingSuggestions = suggestions
@@ -108,7 +119,7 @@ export function presetCollection(collection) {
108119
109120 const leadingNamesStripped = searchable
110121 . filter ( a => leading ( a . searchNameStripped ( ) ) || a . searchAliasesStripped ( ) . some ( leading ) )
111- . sort ( sortPresets ( 'searchNameStripped' ) ) ;
122+ . sort ( sortPresets ( 'searchNameStripped' , 'searchAliasesStripped' ) ) ;
112123
113124 const leadingSuggestionsStripped = suggestions
114125 . filter ( a => leadingStrict ( a . searchNameStripped ( ) ) )
0 commit comments