diff --git a/src/algos/fzf/parser.rs b/src/algos/fzf/parser.rs index d355330..458badc 100644 --- a/src/algos/fzf/parser.rs +++ b/src/algos/fzf/parser.rs @@ -35,6 +35,12 @@ impl core::fmt::Debug for FzfParser { } impl FzfParser { + /// TODO: docs + #[inline] + pub fn new() -> Self { + Self::default() + } + /// TODO: docs #[inline] pub fn parse<'a>(&'a mut self, query: &str) -> FzfQuery<'a> { @@ -85,13 +91,20 @@ impl FzfParser { num_conditions += 1; } - FzfQuery::new(&self.conditions[..num_conditions]) + FzfQuery::new_extended(&self.conditions[..num_conditions]) } /// TODO: docs #[inline] - pub fn new() -> Self { - Self::default() + pub fn parse_not_extended<'a>(&'a mut self, query: &str) -> FzfQuery<'a> { + let mut char_len = 0; + + for ch in query.chars() { + self.chars[char_len] = ch; + char_len += 1; + } + + FzfQuery::new_not_extended(&self.chars[..char_len]) } } diff --git a/src/algos/fzf/query.rs b/src/algos/fzf/query.rs index f0aaae0..9655573 100644 --- a/src/algos/fzf/query.rs +++ b/src/algos/fzf/query.rs @@ -47,7 +47,7 @@ impl<'a> FzfQuery<'a> { /// TODO: docs #[inline] - pub(super) fn new(conditions: &'a [Condition<'a>]) -> Self { + pub(super) fn new_extended(conditions: &'a [Condition<'a>]) -> Self { // If there's only one condition with a single pattern, and that // pattern is fuzzy, then we can use the non-extended search mode. if conditions.len() == 1 { @@ -68,6 +68,12 @@ impl<'a> FzfQuery<'a> { Self { search_mode: SearchMode::Extended(conditions) } } + + /// TODO: docs + #[inline] + pub(super) fn new_not_extended(chars: &'a [char]) -> Self { + Self { search_mode: SearchMode::NotExtended(Pattern::parse(chars)) } + } } /// TODO: docs