Skip to content

Commit 7b117d5

Browse files
committed
Give higher score to fuzzy matches that start with same string
1 parent 69916dc commit 7b117d5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/utils/Utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,9 @@ export function findFuzzy(target: string[], search: string): string | undefined
698698
filteredCandidates = candidates.filter(t => caps(t).includes(search[0].toUpperCase()))
699699
if (filteredCandidates.length != 0) candidates = filteredCandidates
700700

701+
filteredCandidates = candidates.filter(t => searchClean(t).startsWith(cleaned))
702+
if (filteredCandidates.length != 0) candidates = filteredCandidates
703+
701704
filteredCandidates = candidates.filter(t => caps(t) == caps(search))
702705
if (filteredCandidates.length != 0) candidates = filteredCandidates
703706

@@ -729,6 +732,8 @@ export function findFuzzyBestCandidates(target: string[], search: string, amount
729732
d += 1
730733
if (caps(t).includes(search[0]?.toUpperCase()))
731734
d += 1.5
735+
if (searchClean(t).startsWith(cleaned))
736+
d += 1
732737
if (caps(t) == caps(search))
733738
d += 0.5
734739

0 commit comments

Comments
 (0)