diff --git a/scripts/publish.sh b/scripts/publish.sh index 84b17ead..86330afd 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -1,6 +1,7 @@ cargo publish -p yazi-shared cargo publish -p yazi-config cargo publish -p yazi-proxy +cargo publish -p yazi-fs cargo publish -p yazi-adapter cargo publish -p yazi-boot cargo publish -p yazi-dds diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 2398f28d..6343c8ae 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -298,5 +298,5 @@ keymap = [ { on = "", run = "arrow 1", desc = "Move cursor down" }, # Filtering - { on = "/", run = "filter", desc = "Apply a filter for the help items" }, + { on = "f", run = "filter", desc = "Apply a filter for the help items" }, ] diff --git a/yazi-core/src/help/commands/escape.rs b/yazi-core/src/help/commands/escape.rs index 2d6c58a3..8384ac75 100644 --- a/yazi-core/src/help/commands/escape.rs +++ b/yazi-core/src/help/commands/escape.rs @@ -4,10 +4,11 @@ use crate::help::Help; impl Help { pub fn escape(&mut self, _: Cmd) { - if self.in_filter.is_none() { + if self.keyword().is_none() { return self.toggle(self.layer); } + self.keyword = String::new(); self.in_filter = None; self.filter_apply(); render!(); diff --git a/yazi-core/src/help/help.rs b/yazi-core/src/help/help.rs index cde803c4..620f9e6d 100644 --- a/yazi-core/src/help/help.rs +++ b/yazi-core/src/help/help.rs @@ -14,7 +14,7 @@ pub struct Help { pub(super) bindings: Vec<&'static Control>, // Filter - keyword: Option, + pub(super) keyword: String, pub(super) in_filter: Option, pub(super) offset: usize, @@ -29,7 +29,7 @@ impl Help { self.visible = !self.visible; self.layer = layer; - self.keyword = Some(String::new()); + self.keyword = String::new(); self.in_filter = None; self.filter_apply(); @@ -65,18 +65,16 @@ impl Help { } pub(super) fn filter_apply(&mut self) { - let kw = self.in_filter.as_ref().map(|i| i.value()).filter(|v| !v.is_empty()); - if self.keyword.as_deref() == kw { - return; - } + let kw = self.in_filter.as_ref().map_or("", |i| i.value()); - if let Some(kw) = kw { - self.bindings = KEYMAP.get(self.layer).iter().filter(|&c| c.contains(kw)).collect(); - } else { + if kw.is_empty() { + self.keyword = String::new(); self.bindings = KEYMAP.get(self.layer).iter().collect(); + } else if self.keyword != kw { + self.keyword = kw.to_owned(); + self.bindings = KEYMAP.get(self.layer).iter().filter(|&c| c.contains(kw)).collect(); } - self.keyword = kw.map(|s| s.to_owned()); self.arrow(0); } } @@ -89,8 +87,8 @@ impl Help { .in_filter .as_ref() .map(|i| i.value()) - .or(self.keyword.as_deref()) - .map(|s| format!("/{}", s)) + .or(Some(self.keyword.as_str()).filter(|&s| !s.is_empty())) + .map(|s| format!("Filter: {}", s)) } // --- Bindings diff --git a/yazi-fm/src/help/layout.rs b/yazi-fm/src/help/layout.rs index 2bbfdeba..f0ba75da 100644 --- a/yazi-fm/src/help/layout.rs +++ b/yazi-fm/src/help/layout.rs @@ -1,5 +1,5 @@ use ratatui::{buffer::Buffer, layout::{self, Constraint, Rect}, text::Line, widgets::Widget}; -use yazi_config::THEME; +use yazi_config::{KEYMAP, THEME}; use super::Bindings; use crate::Ctx; @@ -10,6 +10,13 @@ pub(crate) struct Layout<'a> { impl<'a> Layout<'a> { pub fn new(cx: &'a Ctx) -> Self { Self { cx } } + + fn tips() -> String { + match KEYMAP.help.iter().find(|&c| c.run.iter().any(|c| c.name == "filter")) { + Some(c) => format!(" (Press `{}` to filter)", c.on()), + None => String::new(), + } + } } impl<'a> Widget for Layout<'a> { @@ -19,7 +26,7 @@ impl<'a> Widget for Layout<'a> { let chunks = layout::Layout::vertical([Constraint::Fill(1), Constraint::Length(1)]).split(area); Line::styled( - help.keyword().unwrap_or_else(|| format!("{}.help", help.layer)), + help.keyword().unwrap_or_else(|| format!("{}.help{}", help.layer, Self::tips())), THEME.help.footer, ) .render(chunks[1], buf);