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(
13
13
14
14
const inputThreshold = input . length / 2 ;
15
15
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 ;
17
17
const distance = lexicalDistance . measure ( option , threshold ) ;
18
18
if ( distance !== undefined ) {
19
19
optionsByDistance [ option ] = distance ;
@@ -68,13 +68,17 @@ class LexicalDistance {
68
68
return 1 ;
69
69
}
70
70
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
+ }
73
77
74
78
const aLength = a . length ;
75
79
const bLength = b . length ;
76
80
77
- if ( Math . abs ( aLength - bLength ) > threshold ) {
81
+ if ( aLength - bLength > threshold ) {
78
82
return undefined ;
79
83
}
80
84
You can’t perform that action at this time.
0 commit comments