summaryrefslogtreecommitdiffstats
path: root/src/pattern
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-08-03 20:49:25 +0200
committerCanop <cano.petrole@gmail.com>2021-08-04 13:25:29 +0200
commitc68e7f3bd12ad14214e074d90c1640d8b2536801 (patch)
tree797741ea2fae240960a9aa03ce3dadb79cb29856 /src/pattern
parent3123abc98b2f2e8e52da3ecce96c690341e75c11 (diff)
improve scrolling behaviors
Especially move the selection when you're at one end and you try to scroll the blocked way. Fix #419
Diffstat (limited to 'src/pattern')
-rw-r--r--src/pattern/content_regex_pattern.rs4
-rw-r--r--src/pattern/pattern.rs32
2 files changed, 18 insertions, 18 deletions
diff --git a/src/pattern/content_regex_pattern.rs b/src/pattern/content_regex_pattern.rs
index 3a27767..052ac4a 100644
--- a/src/pattern/content_regex_pattern.rs
+++ b/src/pattern/content_regex_pattern.rs
@@ -57,11 +57,11 @@ impl ContentRegexPattern {
if !candidate.regular_file || is_path_binary(&candidate.path) {
return None;
}
- match self.has_match(&candidate.path) {
+ match self.has_match(candidate.path) {
Ok(true) => Some(1),
Ok(false) => None,
Err(e) => {
- debug!("error while scanning {:?} : {:?}", &candidate.path, e);
+ debug!("error while scanning {:?} : {:?}", candidate.path, e);
None
}
}
diff --git a/src/pattern/pattern.rs b/src/pattern/pattern.rs
index 36feb21..bc77576 100644
--- a/src/pattern/pattern.rs
+++ b/src/pattern/pattern.rs
@@ -157,14 +157,14 @@ impl Pattern {
pub fn score_of(&self, candidate: Candidate) -> Option<i32> {
match self {
- Self::NameExact(ep) => ep.score_of(&candidate.name),
- Self::NameFuzzy(fp) => fp.score_of(&candidate.name),
- Self::NameRegex(rp) => rp.find(&candidate.name).map(|m| m.score),
- Self::NameTokens(tp) => tp.score_of(&candidate.name),
- Self::PathExact(ep) => ep.score_of(&candidate.subpath),
- Self::PathFuzzy(fp) => fp.score_of(&candidate.subpath),
- Self::PathRegex(rp) => rp.find(&candidate.subpath).map(|m| m.score),
- Self::PathTokens(tp) => tp.score_of(&candidate.subpath),
+ Self::NameExact(ep) => ep.score_of(candidate.name),
+ Self::NameFuzzy(fp) => fp.score_of(candidate.name),
+ Self::NameRegex(rp) => rp.find(candidate.name).map(|m| m.score),
+ Self::NameTokens(tp) => tp.score_of(candidate.name),
+ Self::PathExact(ep) => ep.score_of(candidate.subpath),
+ Self::PathFuzzy(fp) => fp.score_of(candidate.subpath),
+ Self::PathRegex(rp) => rp.find(candidate.subpath).map(|m| m.score),
+ Self::PathTokens(tp) => tp.score_of(candidate.subpath),
Self::ContentExact(cp) => cp.score_of(candidate),
Self::ContentRegex(cp) => cp.score_of(candidate),
Self::Composite(cp) => cp.score_of(candidate),
@@ -174,14 +174,14 @@ impl Pattern {
pub fn score_of_string(&self, candidate: &str) -> Option<i32> {
match self {
- Self::NameExact(ep) => ep.score_of(&candidate),
- Self::NameFuzzy(fp) => fp.score_of(&candidate),
- Self::NameRegex(rp) => rp.find(&candidate).map(|m| m.score),
- Self::NameTokens(tp) => tp.score_of(&candidate),
- Self::PathExact(ep) => ep.score_of(&candidate),
- Self::PathFuzzy(fp) => fp.score_of(&candidate),
- Self::PathRegex(rp) => rp.find(&candidate).map(|m| m.score),
- Self::PathTokens(tp) => tp.score_of(&candidate),
+ Self::NameExact(ep) => ep.score_of(candidate),
+ Self::NameFuzzy(fp) => fp.score_of(candidate),
+ Self::NameRegex(rp) => rp.find(candidate).map(|m| m.score),
+ Self::NameTokens(tp) => tp.score_of(candidate),
+ Self::PathExact(ep) => ep.score_of(candidate),
+ Self::PathFuzzy(fp) => fp.score_of(candidate),
+ Self::PathRegex(rp) => rp.find(candidate).map(|m| m.score),
+ Self::PathTokens(tp) => tp.score_of(candidate),
Self::ContentExact(_) => None, // this isn't suitable
Self::ContentRegex(_) => None, // this isn't suitable
Self::Composite(cp) => cp.score_of_string(candidate),