File tree Expand file tree Collapse file tree 1 file changed +20
-23
lines changed
Expand file tree Collapse file tree 1 file changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,25 @@ export const NO_GROUP = {
99 priority : Priority . NORMAL ,
1010} ;
1111
12+ const fuseOptions : Fuse . IFuseOptions < ActionImpl > = {
13+ keys : [
14+ {
15+ name : "name" ,
16+ weight : 0.5 ,
17+ } ,
18+ {
19+ name : "keywords" ,
20+ getFn : ( item ) => ( item . keywords ?? "" ) . split ( "," ) ,
21+ weight : 0.5 ,
22+ } ,
23+ "subtitle" ,
24+ ] ,
25+ includeScore : true ,
26+ includeMatches : true ,
27+ threshold : 0.2 ,
28+ minMatchCharLength : 1 ,
29+ } ;
30+
1231function order ( a , b ) {
1332 /**
1433 * Larger the priority = higher up the list
@@ -74,29 +93,7 @@ export function useMatches() {
7493 return getDeepResults ( rootResults ) ;
7594 } , [ getDeepResults , rootResults , emptySearch ] ) ;
7695
77- const fuseOptions = {
78- keys : [
79- {
80- name : "name" ,
81- weight : 0.5 ,
82- } ,
83- {
84- name : "keywords" ,
85- getFn : ( item ) => item . keywords . split ( "," ) , // make keyword an array. so fuse can look through words individually
86- weight : 0.5 ,
87- } ,
88- "subtitle" ,
89- ] ,
90- includeScore : true ,
91- includeMatches : true ,
92- threshold : 0.2 ,
93- minMatchCharLength : 1 ,
94- tokenize : ( str ) => {
95- // Example: Preserve hyphens and special characters as separate tokens
96- return str . split ( / [ \s \- , . ! ( ) ] + / ) . filter ( Boolean ) ;
97- } ,
98- } ;
99- const fuse = new Fuse ( filtered , fuseOptions ) ;
96+ const fuse = React . useMemo ( ( ) => new Fuse ( filtered , fuseOptions ) , [ filtered ] ) ;
10097
10198 const matches = useInternalMatches ( filtered , search , fuse ) ;
10299
You can’t perform that action at this time.
0 commit comments