diff --git a/yazi-config/preset/keymap.toml b/yazi-config/preset/keymap.toml index 58d84b60..2c9e5b8e 100644 --- a/yazi-config/preset/keymap.toml +++ b/yazi-config/preset/keymap.toml @@ -192,11 +192,11 @@ keymap = [ { on = [ "" ], exec = "move 1", desc = "Move forward a character" }, # Word-wise movement - { on = [ "b" ], exec = "backward", desc = "Move back to the start of the current or previous word" }, - { on = [ "w" ], exec = "forward", desc = "Move forward to the start of the next word" }, - { on = [ "e" ], exec = "forward --end-of-word", desc = "Move forward to the end of the current or next word" }, - { on = [ "" ], exec = "backward", desc = "Move back to the start of the current or previous word" }, - { on = [ "" ], exec = "forward --after-last-char", desc = "Move forward to the end of the current or next word" }, + { on = [ "b" ], exec = "backward", desc = "Move back to the start of the current or previous word" }, + { on = [ "w" ], exec = "forward", desc = "Move forward to the start of the next word" }, + { on = [ "e" ], exec = "forward --end-of-word", desc = "Move forward to the end of the current or next word" }, + { on = [ "" ], exec = "backward", desc = "Move back to the start of the current or previous word" }, + { on = [ "" ], exec = "forward --end-of-word", desc = "Move forward to the end of the current or next word" }, # Line-wise movement { on = [ "0" ], exec = "move -999", desc = "Move to the BOL" }, diff --git a/yazi-config/src/popup/offset.rs b/yazi-config/src/popup/offset.rs index d8524321..1a36860b 100644 --- a/yazi-config/src/popup/offset.rs +++ b/yazi-config/src/popup/offset.rs @@ -32,3 +32,8 @@ impl TryFrom> for Offset { }) } } + +impl Offset { + #[inline] + pub fn line() -> Self { Self { x: 0, y: 0, width: u16::MAX, height: 1 } } +} diff --git a/yazi-core/src/help/commands/filter.rs b/yazi-core/src/help/commands/filter.rs index 54865299..0721bd43 100644 --- a/yazi-core/src/help/commands/filter.rs +++ b/yazi-core/src/help/commands/filter.rs @@ -1,6 +1,6 @@ -use yazi_config::keymap::Exec; +use yazi_config::{keymap::Exec, popup::{Offset, Origin, Position}}; -use crate::help::Help; +use crate::{help::Help, input::Input}; pub struct Opt; @@ -10,7 +10,10 @@ impl From<&Exec> for Opt { impl Help { pub fn filter(&mut self, _: impl Into) -> bool { - self.in_filter = Some(Default::default()); + let mut input = Input::default(); + input.position = Position::new(Origin::BottomLeft, Offset::line()); + + self.in_filter = Some(input); self.filter_apply(); true } diff --git a/yazi-core/src/help/help.rs b/yazi-core/src/help/help.rs index 97696135..a50f8641 100644 --- a/yazi-core/src/help/help.rs +++ b/yazi-core/src/help/help.rs @@ -1,3 +1,4 @@ +use crossterm::event::KeyCode; use unicode_width::UnicodeWidthStr; use yazi_config::{keymap::{Control, Key, KeymapLayer}, KEYMAP}; use yazi_shared::Term; @@ -65,11 +66,14 @@ impl Help { return true; } - if input.type_(key) { - return self.filter_apply(); - } + let b = match &key { + Key { code: KeyCode::Backspace, shift: false, ctrl: false, alt: false } => { + input.backspace(false) + } + _ => input.type_(key), + }; - false + if b { self.filter_apply() } else { false } } } diff --git a/yazi-core/src/input/commands/backspace.rs b/yazi-core/src/input/commands/backspace.rs index 2d74608c..8828796a 100644 --- a/yazi-core/src/input/commands/backspace.rs +++ b/yazi-core/src/input/commands/backspace.rs @@ -9,6 +9,9 @@ pub struct Opt { impl From<&Exec> for Opt { fn from(e: &Exec) -> Self { Self { under: e.named.contains_key("under") } } } +impl From for Opt { + fn from(under: bool) -> Self { Self { under } } +} impl Input { pub fn backspace(&mut self, opt: impl Into) -> bool { diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index a408d18a..c2d3fad2 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -13,10 +13,10 @@ impl<'a> Executor<'a> { if self.cx.which.visible { return self.cx.which.press(key); } - if self.cx.input.visible && self.cx.input.type_(&key) { + if self.cx.help.visible && self.cx.help.type_(&key) { return true; } - if self.cx.help.visible && self.cx.help.type_(&key) { + if self.cx.input.visible && self.cx.input.type_(&key) { return true; }