feat(service): Add isolate_with plugin query config
This query parameter will isolate search results when the specific regex query is matched.
This commit is contained in:
parent
c330552c20
commit
e7e6007e26
4 changed files with 26 additions and 0 deletions
|
|
@ -49,6 +49,13 @@ pub struct PluginQuery {
|
|||
#[serde(default)]
|
||||
pub isolate: bool,
|
||||
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "Option::is_none",
|
||||
with = "::serde_with::rust::unwrap_or_skip"
|
||||
)]
|
||||
pub isolate_with: Option<Cow<'static, str>>,
|
||||
|
||||
#[serde(default)]
|
||||
pub no_sort: bool,
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub const CONFIG: PluginConfig = PluginConfig {
|
|||
query: PluginQuery {
|
||||
help: None,
|
||||
isolate: true,
|
||||
isolate_with: None,
|
||||
no_sort: true,
|
||||
persistent: false,
|
||||
priority: PluginPriority::Default,
|
||||
|
|
|
|||
|
|
@ -79,6 +79,8 @@ pub struct PluginConnector {
|
|||
/// this plugin to spawn as a background service
|
||||
pub init: Box<dyn Fn() -> Sender<Request>>,
|
||||
|
||||
pub isolate_regex: Option<Regex>,
|
||||
|
||||
/// A compiled regular expression that a query must match
|
||||
/// for the launcher service to justify spawning and sending
|
||||
/// queries to this plugin
|
||||
|
|
@ -93,11 +95,13 @@ impl PluginConnector {
|
|||
pub fn new(
|
||||
config: PluginConfig,
|
||||
regex: Option<Regex>,
|
||||
isolate_regex: Option<Regex>,
|
||||
init: Box<dyn Fn() -> Sender<Request> + Send>,
|
||||
) -> Self {
|
||||
Self {
|
||||
config,
|
||||
init,
|
||||
isolate_regex,
|
||||
regex,
|
||||
sender: None,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue