fix: sort and hidden commands should update mime-type for paged files promptly

This commit is contained in:
sxyazi 2024-01-06 05:14:54 +08:00
parent 9bdbc55117
commit b229c8a5e3
No known key found for this signature in database
8 changed files with 13 additions and 11 deletions

View file

@ -94,7 +94,7 @@ impl Folder {
let new = self.cursor / limit; let new = self.cursor / limit;
if mem::replace(&mut self.page, new) != new || force { if mem::replace(&mut self.page, new) != new || force {
Manager::_update_pages_by(new, &self.cwd); Manager::_update_paged_by(new, &self.cwd);
} }
} }

View file

@ -17,5 +17,5 @@ mod tab_swap;
mod tab_switch; mod tab_switch;
mod update_files; mod update_files;
mod update_mimetype; mod update_mimetype;
mod update_pages; mod update_paged;
mod yank; mod yank;

View file

@ -23,6 +23,6 @@ impl Manager {
} }
self.hover(None); self.hover(None);
self.update_pages((), tasks); self.update_paged((), tasks);
} }
} }

View file

@ -34,7 +34,7 @@ impl Manager {
if self.current_mut().update(op) { if self.current_mut().update(op) {
self.current_mut().repos(hovered.as_ref()); self.current_mut().repos(hovered.as_ref());
Self::_hover(None); // Re-hover in next loop Self::_hover(None); // Re-hover in next loop
Self::_update_pages(); // Update for paged files in next loop Self::_update_paged(); // Update for paged files in next loop
} }
if calc { if calc {

View file

@ -23,19 +23,19 @@ impl From<()> for Opt {
impl Manager { impl Manager {
#[inline] #[inline]
pub fn _update_pages() { pub fn _update_paged() {
emit!(Call(Exec::call("update_pages", vec![]).vec(), Layer::Manager)); emit!(Call(Exec::call("update_paged", vec![]).vec(), Layer::Manager));
} }
#[inline] #[inline]
pub fn _update_pages_by(page: usize, only_if: &Url) { pub fn _update_paged_by(page: usize, only_if: &Url) {
emit!(Call( emit!(Call(
Exec::call("update_pages", vec![page.to_string()]).with("only-if", only_if.to_string()).vec(), Exec::call("update_paged", vec![page.to_string()]).with("only-if", only_if.to_string()).vec(),
Layer::Manager Layer::Manager
)); ));
} }
pub fn update_pages(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) { pub fn update_paged(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) {
let Ok(opt) = opt.try_into() else { let Ok(opt) = opt.try_into() else {
return; return;
}; };

View file

@ -18,5 +18,6 @@ impl Tab {
} else if self.current.hovered().is_some_and(|f| f.is_dir()) { } else if self.current.hovered().is_some_and(|f| f.is_dir()) {
Manager::_peek(true); Manager::_peek(true);
} }
Manager::_update_paged();
} }
} }

View file

@ -3,7 +3,7 @@ use std::str::FromStr;
use yazi_config::manager::SortBy; use yazi_config::manager::SortBy;
use yazi_shared::event::Exec; use yazi_shared::event::Exec;
use crate::tab::Tab; use crate::{manager::Manager, tab::Tab};
impl Tab { impl Tab {
pub fn sort(&mut self, e: &Exec) { pub fn sort(&mut self, e: &Exec) {
@ -15,5 +15,6 @@ impl Tab {
self.conf.sort_dir_first = e.named.contains_key("dir-first"); self.conf.sort_dir_first = e.named.contains_key("dir-first");
self.apply_files_attrs(); self.apply_files_attrs();
Manager::_update_paged();
} }
} }

View file

@ -108,7 +108,7 @@ impl<'a> Executor<'a> {
on!(MANAGER, update_files, &self.app.cx.tasks); on!(MANAGER, update_files, &self.app.cx.tasks);
on!(MANAGER, update_mimetype, &self.app.cx.tasks); on!(MANAGER, update_mimetype, &self.app.cx.tasks);
on!(MANAGER, update_pages, &self.app.cx.tasks); on!(MANAGER, update_paged, &self.app.cx.tasks);
on!(MANAGER, hover); on!(MANAGER, hover);
on!(MANAGER, peek); on!(MANAGER, peek);
on!(MANAGER, seek); on!(MANAGER, seek);