File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
src/vonal_daemon/plugins/launcher Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,12 @@ pub struct Finder {
27
27
cache : Vec < AppIndex > ,
28
28
}
29
29
30
- const MAXIMUM_NUMBER_OF_RESULTS : usize = 10 ;
31
-
32
30
impl Finder {
33
31
pub fn new ( indices : Vec < AppIndex > ) -> Self {
34
32
Self { cache : indices }
35
33
}
36
34
37
- pub fn find ( & self , query : & str ) -> Vec < AppMatch < ' _ > > {
35
+ pub fn find ( & self , query : & str , number_of_results : usize ) -> Vec < AppMatch < ' _ > > {
38
36
let mut results: Vec < _ > = self
39
37
. cache
40
38
. iter ( )
@@ -66,8 +64,8 @@ impl Finder {
66
64
} )
67
65
. collect ( ) ;
68
66
69
- limited_selection_sort:: sort ( & mut results, MAXIMUM_NUMBER_OF_RESULTS ) ;
70
- results. truncate ( MAXIMUM_NUMBER_OF_RESULTS ) ;
67
+ limited_selection_sort:: sort ( & mut results, number_of_results ) ;
68
+ results. truncate ( number_of_results ) ;
71
69
results
72
70
}
73
71
}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub struct Launcher {
21
21
list : ListState ,
22
22
config_prefix : String ,
23
23
config_index_path : bool ,
24
+ config_number_of_results : usize ,
24
25
}
25
26
26
27
impl Launcher {
@@ -53,7 +54,7 @@ impl Launcher {
53
54
54
55
fn find_apps ( & self , query : & str ) -> Vec < AppIndex > {
55
56
self . finder
56
- . find ( query)
57
+ . find ( query, self . config_number_of_results )
57
58
. into_iter ( )
58
59
. map ( |app_match| app_match. index )
59
60
. cloned ( )
@@ -147,6 +148,7 @@ impl Plugin for Launcher {
147
148
builder. group ( "launcher_plugin" , |builder| {
148
149
self . config_prefix = builder. get_or_create ( "prefix" , "" . to_string ( ) ) ?;
149
150
self . config_index_path = builder. get_or_create ( "index_path" , true ) ?;
151
+ self . config_number_of_results = builder. get_or_create ( "number_of_results" , 7 ) ?;
150
152
self . reindex_apps ( ) ;
151
153
Ok ( ( ) )
152
154
} ) ?;
You can’t perform that action at this time.
0 commit comments