Skip to content

Commit e2c7071

Browse files
committed
Add number of results config
1 parent 4aba481 commit e2c7071

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/vonal_daemon/plugins/launcher/finder/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ pub struct Finder {
2727
cache: Vec<AppIndex>,
2828
}
2929

30-
const MAXIMUM_NUMBER_OF_RESULTS: usize = 10;
31-
3230
impl Finder {
3331
pub fn new(indices: Vec<AppIndex>) -> Self {
3432
Self { cache: indices }
3533
}
3634

37-
pub fn find(&self, query: &str) -> Vec<AppMatch<'_>> {
35+
pub fn find(&self, query: &str, number_of_results: usize) -> Vec<AppMatch<'_>> {
3836
let mut results: Vec<_> = self
3937
.cache
4038
.iter()
@@ -66,8 +64,8 @@ impl Finder {
6664
})
6765
.collect();
6866

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);
7169
results
7270
}
7371
}

src/vonal_daemon/plugins/launcher/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub struct Launcher {
2121
list: ListState,
2222
config_prefix: String,
2323
config_index_path: bool,
24+
config_number_of_results: usize,
2425
}
2526

2627
impl Launcher {
@@ -53,7 +54,7 @@ impl Launcher {
5354

5455
fn find_apps(&self, query: &str) -> Vec<AppIndex> {
5556
self.finder
56-
.find(query)
57+
.find(query, self.config_number_of_results)
5758
.into_iter()
5859
.map(|app_match| app_match.index)
5960
.cloned()
@@ -147,6 +148,7 @@ impl Plugin for Launcher {
147148
builder.group("launcher_plugin", |builder| {
148149
self.config_prefix = builder.get_or_create("prefix", "".to_string())?;
149150
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)?;
150152
self.reindex_apps();
151153
Ok(())
152154
})?;

0 commit comments

Comments
 (0)