feat(core): add built-in filter in search bar
This commit is contained in:
parent
d4cede1862
commit
0f361ba6d0
|
@ -48,7 +48,7 @@ pub fn search_main(matches: &ArgMatches, icon_paths: &IconPaths) -> i32 {
|
|||
// Overwrite the icon
|
||||
config.icon = icon_paths.logo.as_deref().map(|path| path.to_string_lossy().to_string());
|
||||
|
||||
let algorithm = algorithm::get_algorithm(&config.algorithm);
|
||||
let algorithm = algorithm::get_algorithm(&config.algorithm, true);
|
||||
|
||||
let search = generator::generate(config);
|
||||
let result = show(search, algorithm);
|
||||
|
|
|
@ -32,6 +32,7 @@ pub struct MatchSummary<'a> {
|
|||
pub id: i32,
|
||||
pub label: &'a str,
|
||||
pub tag: Option<&'a str>,
|
||||
pub is_builtin: bool,
|
||||
}
|
||||
|
||||
pub struct MatchSelectorAdapter<'a> {
|
||||
|
@ -60,6 +61,7 @@ impl<'a> MatchSelector for MatchSelectorAdapter<'a> {
|
|||
id: m.id.to_string(),
|
||||
label: clipped_label.to_string(),
|
||||
tag: m.tag.map(String::from),
|
||||
is_builtin: m.is_builtin,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
|
|
@ -128,11 +128,13 @@ impl<'a> super::engine::process::middleware::match_select::MatchProvider<'a>
|
|||
id: m.id,
|
||||
label: m.description(),
|
||||
tag: m.cause_description(),
|
||||
is_builtin: false,
|
||||
},
|
||||
MatchVariant::Builtin(m) => MatchSummary {
|
||||
id: m.id,
|
||||
label: m.label,
|
||||
tag: m.triggers.first().map(String::as_ref),
|
||||
is_builtin: true,
|
||||
},
|
||||
})
|
||||
.collect()
|
||||
|
|
|
@ -32,6 +32,7 @@ pub struct SearchItem {
|
|||
pub id: String,
|
||||
pub label: String,
|
||||
pub tag: Option<String>,
|
||||
pub is_builtin: bool,
|
||||
}
|
||||
|
||||
pub trait FormUI {
|
||||
|
|
|
@ -75,6 +75,7 @@ struct ModuloSearchItemConfig<'a> {
|
|||
id: &'a str,
|
||||
label: &'a str,
|
||||
trigger: Option<&'a str>,
|
||||
is_builtin: bool,
|
||||
}
|
||||
|
||||
// TODO: test
|
||||
|
@ -83,5 +84,6 @@ fn convert_items<'a>(items: &'a [SearchItem]) -> Vec<ModuloSearchItemConfig<'a>>
|
|||
id: &item.id,
|
||||
label: &item.label,
|
||||
trigger: item.tag.as_deref(),
|
||||
is_builtin: item.is_builtin,
|
||||
}).collect()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user