summaryrefslogtreecommitdiffstats
path: root/src/tree
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-02-15 17:14:06 +0100
committerCanop <cano.petrole@gmail.com>2022-02-15 17:14:06 +0100
commitaf3a1f3c3290f6b88c748bde656ef99ada1f3c7b (patch)
tree4a8ce6c617602b80c8de9d10b220694ce221275d /src/tree
parent8ca1c3d09aaab7883f8ce9394fe7c43d96308903 (diff)
:previous_dir and :next_dir internals
Fix #502
Diffstat (limited to 'src/tree')
-rw-r--r--src/tree/tree.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/tree/tree.rs b/src/tree/tree.rs
index 822f4e5..0ff91fe 100644
--- a/src/tree/tree.rs
+++ b/src/tree/tree.rs
@@ -367,14 +367,20 @@ impl Tree {
}
false
}
- pub fn try_select_previous_match(&mut self, page_height: usize) -> bool {
+ pub fn try_select_previous_filtered<F>(
+ &mut self,
+ filter: F,
+ page_height: usize,
+ ) -> bool where
+ F: Fn(&TreeLine) -> bool,
+ {
for di in (0..self.lines.len()).rev() {
let idx = (self.selection + di) % self.lines.len();
let line = &self.lines[idx];
if !line.is_selectable() {
continue;
}
- if !line.direct_match {
+ if !filter(line) {
continue;
}
if line.score > 0 {
@@ -385,14 +391,20 @@ impl Tree {
}
false
}
- pub fn try_select_next_match(&mut self, page_height: usize) -> bool {
+ pub fn try_select_next_filtered<F>(
+ &mut self,
+ filter: F,
+ page_height: usize,
+ ) -> bool where
+ F: Fn(&TreeLine) -> bool,
+ {
for di in 0..self.lines.len() {
let idx = (self.selection + di + 1) % self.lines.len();
let line = &self.lines[idx];
if !line.is_selectable() {
continue;
}
- if !line.direct_match {
+ if !filter(line) {
continue;
}
if line.score > 0 {