summaryrefslogtreecommitdiffstats
path: root/src/pattern
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-06-12 15:52:10 +0200
committerCanop <cano.petrole@gmail.com>2022-06-12 15:52:10 +0200
commit0dff3a37ecf87d15f3cc513d129d2c0431a774e0 (patch)
treee10d52adf66d1129000afeaa0d6329fa87cae438 /src/pattern
parentab14c365e3844c232f0e8930d602600d00c25005 (diff)
add examples on search modes in help screen
Fix #559
Diffstat (limited to 'src/pattern')
-rw-r--r--src/pattern/search_mode.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pattern/search_mode.rs b/src/pattern/search_mode.rs
index 8bd70c1..8cadc2d 100644
--- a/src/pattern/search_mode.rs
+++ b/src/pattern/search_mode.rs
@@ -1,6 +1,7 @@
use {
crate::{
+ app::AppContext,
errors::{ConfError, PatternError},
},
fnv::FnvHashMap,
@@ -76,14 +77,22 @@ impl SearchMode {
(Content, Tokens) => None, // unsupported for now - could be but need bench
}
}
- pub fn object(&self) -> SearchObject {
+ /// Return the prefix to type, eg "/" in standard for a name-regex,
+ /// "" for a name-fuzzy, and "ep" for a path-exact
+ pub fn prefix(self, con: &AppContext) -> String {
+ con
+ .search_modes
+ .key(self)
+ .map_or_else(|| "".to_string(), |k| format!("{}/", k))
+ }
+ pub fn object(self) -> SearchObject {
match self {
Self::NameExact | Self::NameFuzzy | Self::NameRegex | Self::NameTokens => SearchObject::Name,
Self::PathExact | Self::PathFuzzy | Self::PathRegex | Self::PathTokens => SearchObject::Path,
Self::ContentExact | Self::ContentRegex => SearchObject::Content,
}
}
- pub fn kind(&self) -> SearchKind {
+ pub fn kind(self) -> SearchKind {
match self {
Self::NameExact => SearchKind::Exact,
Self::NameFuzzy => SearchKind::Fuzzy,