diff options
author | Canop <cano.petrole@gmail.com> | 2020-06-20 07:19:22 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2020-06-20 07:19:22 +0200 |
commit | b398c3deab7527f866c1678b0ffc45071a4b07ee (patch) | |
tree | 8ed9964d049ba5c18e47898b764948ced150d504 | |
parent | 5c0bc1bf298f0bdb299576197b2d1566ce55cd2c (diff) |
fix regex patterns with flags needing a third / to be combined
-rw-r--r-- | src/command/mod.rs | 2 | ||||
-rw-r--r-- | src/command/parts.rs | 1 | ||||
-rw-r--r-- | src/pattern/input_pattern.rs | 3 | ||||
-rw-r--r-- | src/pattern/mod.rs | 6 | ||||
-rw-r--r-- | src/pattern/name_match.rs (renamed from src/pattern/pattern_match.rs) | 11 | ||||
-rw-r--r-- | src/pattern/pattern.rs | 1 | ||||
-rw-r--r-- | src/pattern/pattern_parts.rs (renamed from src/command/pattern_parts.rs) | 2 | ||||
-rw-r--r-- | website/docs/index.md | 2 |
8 files changed, 7 insertions, 21 deletions
diff --git a/src/command/mod.rs b/src/command/mod.rs index 85ba99e..19c5e19 100644 --- a/src/command/mod.rs +++ b/src/command/mod.rs @@ -1,7 +1,6 @@ mod command; mod completion; mod event; -mod pattern_parts; mod parts; mod sequence; mod trigger_type; @@ -11,7 +10,6 @@ pub use { completion::Completions, event::PanelInput, parts::CommandParts, - pattern_parts::PatternParts, sequence::parse_command_sequence, trigger_type::TriggerType, }; diff --git a/src/command/parts.rs b/src/command/parts.rs index 9e045db..a6a98ea 100644 --- a/src/command/parts.rs +++ b/src/command/parts.rs @@ -1,5 +1,4 @@ use { - super::PatternParts, crate::{ pattern::*, verb::VerbInvocation, diff --git a/src/pattern/input_pattern.rs b/src/pattern/input_pattern.rs index 00db930..6e12eae 100644 --- a/src/pattern/input_pattern.rs +++ b/src/pattern/input_pattern.rs @@ -2,9 +2,8 @@ use { super::*, crate::{ app::AppContext, - command::PatternParts, errors::PatternError, - pattern::Pattern, + pattern::{Pattern, PatternParts}, }, bet::BeTree, }; diff --git a/src/pattern/mod.rs b/src/pattern/mod.rs index 686c695..3d8d8b0 100644 --- a/src/pattern/mod.rs +++ b/src/pattern/mod.rs @@ -6,8 +6,9 @@ mod fuzzy_patterns; mod input_pattern; mod operator; mod pattern; -mod pattern_match; +mod name_match; mod pattern_object; +mod pattern_parts; mod regex_patterns; mod search_mode; @@ -17,9 +18,10 @@ pub use { content_pattern::ContentPattern, fuzzy_patterns::FuzzyPattern, input_pattern::InputPattern, - pattern_match::NameMatch, + name_match::NameMatch, pattern::Pattern, pattern_object::PatternObject, + pattern_parts::PatternParts, operator::PatternOperator, regex_patterns::RegexPattern, search_mode::{SearchMode, SearchModeMap, SearchModeMapEntry}, diff --git a/src/pattern/pattern_match.rs b/src/pattern/name_match.rs index 9dd130e..cbb2b0a 100644 --- a/src/pattern/pattern_match.rs +++ b/src/pattern/name_match.rs @@ -7,14 +7,3 @@ pub struct NameMatch { pub pos: Vec<usize>, // positions of the matching chars } -impl Default for NameMatch { - /// default implementation is for example useful to negate an - /// absence of match - fn default() -> Self { - Self { - score: 1, - pos: Vec::new(), - } - } -} - diff --git a/src/pattern/pattern.rs b/src/pattern/pattern.rs index 2442266..088e5e0 100644 --- a/src/pattern/pattern.rs +++ b/src/pattern/pattern.rs @@ -3,7 +3,6 @@ use { super::*, crate::{ app::AppContext, - command::PatternParts, content_search::ContentMatch, errors::PatternError, }, diff --git a/src/command/pattern_parts.rs b/src/pattern/pattern_parts.rs index 2f1b8cd..c4808a1 100644 --- a/src/command/pattern_parts.rs +++ b/src/pattern/pattern_parts.rs @@ -33,7 +33,7 @@ impl PatternParts { self.parts.push(String::new()); } pub fn allow_inter_pattern_token(&self) -> bool { - self.parts.len() == 1 || self.parts.last().unwrap().is_empty() + self.parts.len() != 2 || self.parts.last().unwrap().is_empty() } pub fn is_empty(&self) -> bool { self.core().is_empty() diff --git a/website/docs/index.md b/website/docs/index.md index a094cdd..b76ce83 100644 --- a/website/docs/index.md +++ b/website/docs/index.md @@ -44,7 +44,7 @@ And you have other types of searches, for example searching on file content (sta ![content search](img/20200608-content-search.png) -You may also apply logical operators or combine patterns, for example searching `test` in all files except txt ones could be `!/txt$/&c/test` and searching `carg` both in file names and file contents would be `carg|c/carg`. +You may also apply logical operators or combine patterns, for example searching `test` in all files except json ones could be `!/json$/&c/test` and searching `carg` both in file names and file contents would be `carg|c/carg`. Once the file you want is selected you can |