File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export default function suggestionList(
1313
1414 const inputThreshold = input . length / 2 ;
1515 for ( const option of options ) {
16- const threshold = Math . max ( inputThreshold , option . length / 2 , 1 ) ;
16+ const threshold = Math . max ( inputThreshold , option . length / 2 , 1 ) | 0 ;
1717 const distance = lexicalDistance . measure ( option , threshold ) ;
1818 if ( distance !== undefined ) {
1919 optionsByDistance [ option ] = distance ;
@@ -68,13 +68,17 @@ class LexicalDistance {
6868 return 1 ;
6969 }
7070
71- const a = optionLowerCase ;
72- const b = this . _inputLowerCase ;
71+ let a = optionLowerCase ;
72+ let b = this . _inputLowerCase ;
73+ if ( a . length < b . length ) {
74+ a = b ;
75+ b = optionLowerCase ;
76+ }
7377
7478 const aLength = a . length ;
7579 const bLength = b . length ;
7680
77- if ( Math . abs ( aLength - bLength ) > threshold ) {
81+ if ( aLength - bLength > threshold ) {
7882 return undefined ;
7983 }
8084
You can’t perform that action at this time.
0 commit comments