mirror of
https://github.com/sxyazi/yazi.git
synced 2024-09-11 18:38:19 +03:00
Compare commits
2 Commits
99dc0e389c
...
e489bf3c81
Author | SHA1 | Date | |
---|---|---|---|
|
e489bf3c81 | ||
|
3812ea2d3a |
@ -221,7 +221,7 @@ impl Files {
|
||||
|
||||
let (hidden, items) = if let Some(filter) = &self.filter {
|
||||
urls.into_iter().partition(|u| {
|
||||
(u.is_hidden() && !self.show_hidden) || !u.file_name().is_some_and(|s| filter.matches(s))
|
||||
(!self.show_hidden && u.is_hidden()) || !u.file_name().is_some_and(|s| filter.matches(s))
|
||||
})
|
||||
} else if self.show_hidden {
|
||||
(vec![], urls)
|
||||
|
@ -35,9 +35,10 @@ impl Filter {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
#[derive(Default, PartialEq, Eq)]
|
||||
pub enum FilterCase {
|
||||
Smart,
|
||||
#[default]
|
||||
Sensitive,
|
||||
Insensitive,
|
||||
}
|
||||
|
@ -45,7 +45,9 @@ impl Tab {
|
||||
fn escape_select(&mut self) -> bool { self.select_all(Some(false)) }
|
||||
|
||||
#[inline]
|
||||
fn escape_filter(&mut self) -> bool { self.current.files.set_filter(None) }
|
||||
fn escape_filter(&mut self) -> bool {
|
||||
self.filter_do(super::filter::Opt { query: "", ..Default::default() })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn escape_search(&mut self) -> bool { self.search_stop() }
|
||||
|
@ -5,16 +5,17 @@ use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
||||
use yazi_config::popup::InputCfg;
|
||||
use yazi_shared::{emit, event::Exec, Debounce, InputError, Layer};
|
||||
|
||||
use crate::{folder::{Filter, FilterCase}, input::Input, tab::Tab};
|
||||
use crate::{folder::{Filter, FilterCase}, input::Input, manager::Manager, tab::Tab};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Opt<'a> {
|
||||
query: Option<&'a str>,
|
||||
case: FilterCase,
|
||||
pub query: &'a str,
|
||||
pub case: FilterCase,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Exec> for Opt<'a> {
|
||||
fn from(e: &'a Exec) -> Self {
|
||||
Self { query: e.args.first().map(|s| s.as_str()), case: e.into() }
|
||||
Self { query: e.args.first().map(|s| s.as_str()).unwrap_or_default(), case: e.into() }
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,13 +43,10 @@ impl Tab {
|
||||
|
||||
pub fn filter_do<'a>(&mut self, opt: impl Into<Opt<'a>>) -> bool {
|
||||
let opt = opt.into() as Opt;
|
||||
let Some(query) = opt.query else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let filter = if query.is_empty() {
|
||||
let filter = if opt.query.is_empty() {
|
||||
None
|
||||
} else if let Ok(f) = Filter::new(query, opt.case) {
|
||||
} else if let Ok(f) = Filter::new(opt.query, opt.case) {
|
||||
Some(f)
|
||||
} else {
|
||||
return false;
|
||||
@ -59,7 +57,9 @@ impl Tab {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.current.repos(hovered);
|
||||
if self.current.repos(hovered) {
|
||||
Manager::_hover(None);
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user