update: add find --clear option

run find --clear command to clear find
This commit is contained in:
Yiang 2024-11-27 12:06:22 +08:00
parent 5e48df5126
commit d019fc47fc

View file

@ -14,11 +14,17 @@ pub(super) struct Opt {
pub(super) query: Option<String>, pub(super) query: Option<String>,
pub(super) prev: bool, pub(super) prev: bool,
pub(super) case: FilterCase, pub(super) case: FilterCase,
pub(super) clear: bool,
} }
impl From<Cmd> for Opt { impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self { fn from(mut c: Cmd) -> Self {
Self { query: c.take_first_str(), prev: c.bool("previous"), case: FilterCase::from(&c) } Self {
query: c.take_first_str(),
prev: c.bool("previous"),
clear: c.bool("clear"),
case: FilterCase::from(&c),
}
} }
} }
@ -26,8 +32,15 @@ impl Tab {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn find(&mut self, opt: Opt) { pub fn find(&mut self, opt: Opt) {
tokio::spawn(async move { tokio::spawn(async move {
let rx = InputProxy::show(InputCfg::find(opt.prev)); if opt.clear {
emit!(Call(
Cmd::args("find_do", &[""]),
Layer::Manager
));
return;
}
let rx = InputProxy::show(InputCfg::find(opt.prev));
let rx = Debounce::new(UnboundedReceiverStream::new(rx), Duration::from_millis(50)); let rx = Debounce::new(UnboundedReceiverStream::new(rx), Duration::from_millis(50));
pin!(rx); pin!(rx);