diff --git a/info.plist b/info.plist
index e6edafc..a92ba2a 100644
--- a/info.plist
+++ b/info.plist
@@ -249,6 +249,31 @@ https://github.com/Avivbens/alfred-search-bookmark
variable
slice_amount
+
+ config
+
+ defaultvalue
+ 4
+ markercount
+ 10
+ maxvalue
+ 10
+ minvalue
+ 0
+ onlystoponmarkers
+
+ showmarkers
+
+
+ description
+ A number between 1-10. A higher number would be less accurate, but more dynamic.
+ label
+ Fuzzy search accuracy
+ type
+ slider
+ variable
+ fuzzy_threshold
+
version
2.2.1
diff --git a/src/common/variables.ts b/src/common/variables.ts
index cf20265..0f54fc3 100644
--- a/src/common/variables.ts
+++ b/src/common/variables.ts
@@ -1,4 +1,5 @@
export enum Variables {
PROFILES_LOOKUP = 'lookfor_profiles',
SLICE_AMOUNT = 'slice_amount',
+ FUZZY_THRESHOLD = 'fuzzy_threshold',
}
diff --git a/src/main/bookmarks.ts b/src/main/bookmarks.ts
index 0f0dd9d..f72f419 100644
--- a/src/main/bookmarks.ts
+++ b/src/main/bookmarks.ts
@@ -15,6 +15,11 @@ import { searchBookmarks } from '@services/search.service'
parser: Number,
})
+ const fuzzyThreshold: number = alfredClient.env.getEnv(Variables.FUZZY_THRESHOLD, {
+ defaultValue: 0.4,
+ parser: (input) => Number(input) / 10,
+ })
+
const profiles: string[] = profilesConfig.split(',')
try {
@@ -24,7 +29,7 @@ import { searchBookmarks } from '@services/search.service'
alfredClient.cache.setWithTTL(CACHE_BOOKMARKS_KEY, bookmarks, { maxAge: CACHE_TTL })
}
- const filteredBookmarks = await searchBookmarks(bookmarks, alfredClient.input, sliceAmount)
+ const filteredBookmarks = await searchBookmarks(bookmarks, alfredClient.input, sliceAmount, fuzzyThreshold)
const items: AlfredScriptFilter['items'] = filteredBookmarks.map(({ name, url, profile }) => {
const subtitle = `[${profile}] - ${url}`
diff --git a/src/services/search.service.ts b/src/services/search.service.ts
index ebd1ccc..b4b0791 100644
--- a/src/services/search.service.ts
+++ b/src/services/search.service.ts
@@ -5,6 +5,7 @@ export async function searchBookmarks(
bookmarks: IUIBookmark[],
searchTerm: string,
limit: number,
+ threshold: number,
): Promise {
const Fuse = (await import('fuse.js/min-basic')).default
@@ -12,7 +13,7 @@ export async function searchBookmarks(
keys: SEARCH_FIELDS_CONFIG,
isCaseSensitive: false,
shouldSort: true,
- threshold: 0.4,
+ threshold,
})
const res = fuse.search(searchTerm, { limit })