diff options
author | Canop <cano.petrole@gmail.com> | 2020-06-01 10:14:28 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-06-01 10:14:28 +0200 |
commit | f9a75313b16378e61b64ee36c3bd829397642032 (patch) | |
tree | 6f15446a49da49e7228537ba5acf7c4a5fbf8601 /src/browser/browser_state.rs | |
parent | 928365ae4bf4370b6bed57de1488d347fc5cc644 (diff) |
[WIP] refactoring for new pattern syntax
Diffstat (limited to 'src/browser/browser_state.rs')
-rw-r--r-- | src/browser/browser_state.rs | 38 |
1 files changed, 7 insertions, 31 deletions
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs index 0426b58..c06ab01 100644 --- a/src/browser/browser_state.rs +++ b/src/browser/browser_state.rs @@ -265,10 +265,7 @@ impl AppState for BrowserState { con: &AppContext, ) -> Status { match cmd { - Command::FuzzyPatternEdit(s) if !s.is_empty() => { - Status::new(self.normal_status_message(true), false) - } - Command::RegexEdit(s, _) if !s.is_empty() => { + Command::PatternEdit(_) => { Status::new(self.normal_status_message(true), false) } Command::VerbEdit(invocation) => { @@ -344,40 +341,19 @@ impl AppState for BrowserState { } } - fn on_fuzzy_pattern_edit( + + fn on_pattern( &mut self, - pat: &str, + pat: Pattern, _con: &AppContext, ) -> Result<AppStateCmdResult, ProgramError> { - match pat.len() { - 0 => { - self.filtered_tree = None; - } - _ => { - self.pending_pattern = Pattern::fuzzy(pat); - } + if !pat.is_some() { + self.filtered_tree = None; } + self.pending_pattern = pat; Ok(AppStateCmdResult::Keep) } - fn on_regex_pattern_edit( - &mut self, - pat: &str, - flags: &str, - _con: &AppContext, - ) -> Result<AppStateCmdResult, ProgramError> { - Ok(match Pattern::regex(pat, flags) { - Ok(regex_pattern) => { - self.pending_pattern = regex_pattern; - AppStateCmdResult::Keep - } - Err(e) => { - // FIXME details - AppStateCmdResult::DisplayError(format!("{}", e)) - } - }) - } - fn on_internal( &mut self, internal_exec: &InternalExecution, |