From c335b0272b48dd76a82fec5db4c47f6d89cd95fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Sat, 13 Jan 2024 15:23:18 +0800 Subject: [PATCH] fix: update paged files after filter done (#505) --- yazi-core/src/tab/commands/filter.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/yazi-core/src/tab/commands/filter.rs b/yazi-core/src/tab/commands/filter.rs index d0e79241..a6378f8a 100644 --- a/yazi-core/src/tab/commands/filter.rs +++ b/yazi-core/src/tab/commands/filter.rs @@ -11,11 +11,16 @@ use crate::{folder::{Filter, FilterCase}, input::Input, manager::Manager, tab::T pub struct Opt<'a> { pub query: &'a str, pub case: FilterCase, + pub done: bool, } impl<'a> From<&'a Exec> for Opt<'a> { fn from(e: &'a Exec) -> Self { - Self { query: e.args.first().map(|s| s.as_str()).unwrap_or_default(), case: e.into() } + Self { + query: e.args.first().map(|s| s.as_str()).unwrap_or_default(), + case: e.into(), + done: e.named.contains_key("done"), + } } } @@ -28,11 +33,17 @@ impl Tab { let rx = Debounce::new(UnboundedReceiverStream::new(rx), Duration::from_millis(50)); pin!(rx); - while let Some(Ok(s)) | Some(Err(InputError::Typed(s))) = rx.next().await { + while let Some(result) = rx.next().await { + let done = result.is_ok(); + let (Ok(s) | Err(InputError::Typed(s))) = result else { + continue; + }; + emit!(Call( Exec::call("filter_do", vec![s]) .with_bool("smart", opt.case == FilterCase::Smart) .with_bool("insensitive", opt.case == FilterCase::Insensitive) + .with_bool("done", done) .vec(), Layer::Manager )); @@ -51,6 +62,10 @@ impl Tab { return; }; + if opt.done { + Manager::_update_paged(); // Update for paged files in next loop + } + let hovered = self.current.hovered().map(|f| f.url()); if !self.current.files.set_filter(filter) { return;