Skip to content

Commit

Permalink
Increase errors and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebrody committed Feb 2, 2025
1 parent bd3ac63 commit 8aa1c96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion react/src/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function search(searchIndex: NormalizedSearchIndex, { unnormalizedPattern, maxRe

const results: SearchResult[] = []

const maxErrors = 1
const maxErrors = 2
const maxMatchScore = patternTokens.length * (maxErrors + 1)
const maxPositionScore = patternTokens.length * Math.max(patternTokens.length, searchIndex.lengthOfLongestToken)

Expand Down
1 change: 1 addition & 0 deletions react/unit/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const firstResult = (testFn: (name: string, testBlock: () => void) => void) => (

firstResult(test)('china', 'China')
firstResult(test)('ontario california', 'Ontario city, California, USA')
firstResult(test)('onatrio california', 'Ontario city, California, USA') // Letter flip
firstResult(test)('la canada', 'La Cañada Flintridge city, California, USA')
firstResult(test)('east fiji', 'Eastern, Fiji')
firstResult(test)('london on', 'London Population Center, ON, Canada') // Something in canada
Expand Down

0 comments on commit 8aa1c96

Please sign in to comment.