fix: update paged files after filter done (#505)

This commit is contained in:
三咲雅 · Misaki Masa 2024-01-13 15:23:18 +08:00 committed by GitHub
parent e41266dbe3
commit c335b0272b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;