diff --git a/yazi-config/src/pattern.rs b/yazi-config/src/pattern.rs index 652cafee..922f8394 100644 --- a/yazi-config/src/pattern.rs +++ b/yazi-config/src/pattern.rs @@ -37,10 +37,10 @@ impl Pattern { } #[inline] - pub fn any_file(&self) -> bool { self.inner.as_str() == "*" } + pub fn any_file(&self) -> bool { !self.is_folder && self.inner.as_str() == "*" } #[inline] - pub fn any_dir(&self) -> bool { self.inner.as_str() == "*/" } + pub fn any_dir(&self) -> bool { self.is_folder && self.inner.as_str() == "*" } } impl TryFrom<&str> for Pattern { diff --git a/yazi-config/src/plugin/plugin.rs b/yazi-config/src/plugin/plugin.rs index 00d93d00..34cc8031 100644 --- a/yazi-config/src/plugin/plugin.rs +++ b/yazi-config/src/plugin/plugin.rs @@ -34,12 +34,6 @@ impl Default for Plugin { } let mut shadow = toml::from_str::(&MERGED_YAZI).unwrap().plugin; - if shadow.append_preloaders.iter().any(|r| r.any_file()) { - shadow.preloaders.retain(|r| !r.any_file()); - } - if shadow.append_preloaders.iter().any(|r| r.any_dir()) { - shadow.preloaders.retain(|r| !r.any_dir()); - } if shadow.append_previewers.iter().any(|r| r.any_file()) { shadow.previewers.retain(|r| !r.any_file()); } diff --git a/yazi-core/src/notify/message.rs b/yazi-core/src/notify/message.rs index 0f1d0f3e..9faad177 100644 --- a/yazi-core/src/notify/message.rs +++ b/yazi-core/src/notify/message.rs @@ -42,6 +42,10 @@ impl TryFrom for Message { impl Message { #[inline] pub fn height(&self, width: u16) -> usize { + if width == 0 { + return 0; // In case we can't get the width of the terminal + } + let lines = (self.content.width() as f64 / width as f64).ceil(); lines as usize + NOTIFY_BORDER as usize } diff --git a/yazi-fm/src/app/commands/update_notify.rs b/yazi-fm/src/app/commands/update_notify.rs index a408e1f3..4da856c9 100644 --- a/yazi-fm/src/app/commands/update_notify.rs +++ b/yazi-fm/src/app/commands/update_notify.rs @@ -2,12 +2,13 @@ use crossterm::terminal::WindowSize; use ratatui::layout::Rect; use yazi_shared::{event::Cmd, term::Term}; -use crate::app::App; +use crate::{app::App, notify}; impl App { pub(crate) fn update_notify(&mut self, cmd: Cmd) { - let WindowSize { width, height, .. } = Term::size(); - let area = crate::notify::Layout::available(Rect { x: 0, y: 0, width, height }); + let WindowSize { rows, columns, .. } = Term::size(); + let area = + notify::Layout::available(Rect { x: 0, y: 0, width: columns, height: rows }); self.cx.notify.tick(cmd, area); diff --git a/yazi-fm/src/lives/file.rs b/yazi-fm/src/lives/file.rs index 99e6249f..cffebf27 100644 --- a/yazi-fm/src/lives/file.rs +++ b/yazi-fm/src/lives/file.rs @@ -71,9 +71,7 @@ impl File { Ok(THEME.filetypes.iter().find(|&x| x.matches(me, mime)).map(|x| Style::from(x.style))) }); - reg.add_method("is_hovered", |_, me, ()| { - Ok(matches!(me.folder().hovered(), Some(f) if f.url == me.url)) - }); + reg.add_method("is_hovered", |_, me, ()| Ok(me.idx == me.folder().cursor)); reg.add_method("is_yanked", |lua, me, ()| { let cx = lua.named_registry_value::("cx")?; Ok(if !cx.manager.yanked.contains(&me.url) {