mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
loop through search result
This commit is contained in:
parent
b2d3e39e96
commit
2965a23dbf
1 changed files with 21 additions and 16 deletions
|
|
@ -19,20 +19,21 @@ impl Finder {
|
||||||
|
|
||||||
pub(super) fn arrow(&self, files: &Files, cursor: usize, prev: bool) -> Option<isize> {
|
pub(super) fn arrow(&self, files: &Files, cursor: usize, prev: bool) -> Option<isize> {
|
||||||
if prev {
|
if prev {
|
||||||
files
|
for i in 1..files.len() {
|
||||||
.iter()
|
let index = (cursor + files.len() - i) % files.len();
|
||||||
.take(cursor)
|
if files[index].name().is_some_and(|name| self.matches(name)) {
|
||||||
.rev()
|
return Some((index as isize) - (cursor as isize));
|
||||||
.enumerate()
|
}
|
||||||
.find(|(_, f)| f.name().map_or(false, |n| self.matches(n)))
|
}
|
||||||
.map(|(i, _)| -(i as isize) - 1)
|
None
|
||||||
} else {
|
} else {
|
||||||
files
|
for i in 1..files.len() {
|
||||||
.iter()
|
let index = (cursor + i) % files.len();
|
||||||
.skip(cursor + 1)
|
if files[index].name().is_some_and(|name| self.matches(name)) {
|
||||||
.enumerate()
|
return Some((index as isize) - (cursor as isize));
|
||||||
.find(|(_, f)| f.name().map_or(false, |n| self.matches(n)))
|
}
|
||||||
.map(|(i, _)| i as isize + 1)
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -123,10 +124,14 @@ impl Finder {
|
||||||
|
|
||||||
impl Finder {
|
impl Finder {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn matched(&self) -> &BTreeMap<Url, u8> { &self.matched }
|
pub fn matched(&self) -> &BTreeMap<Url, u8> {
|
||||||
|
&self.matched
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn has_matched(&self) -> bool { !self.matched.is_empty() }
|
pub fn has_matched(&self) -> bool {
|
||||||
|
!self.matched.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn matched_idx(&self, url: &Url) -> Option<u8> {
|
pub fn matched_idx(&self, url: &Url) -> Option<u8> {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue