special case deleting to end of word in vim

This commit is contained in:
Francis Chua 2023-11-12 16:39:15 +00:00
parent e5d05afafb
commit 5c7bbe2e59

View file

@ -1,6 +1,6 @@
use yazi_config::keymap::Exec; use yazi_config::keymap::Exec;
use crate::input::Input; use crate::input::{op::InputOp, Input};
pub struct Opt { pub struct Opt {
end_of_word: bool, end_of_word: bool,
@ -20,8 +20,14 @@ impl Input {
let snap = self.snap(); let snap = self.snap();
let idx = snap.idx(snap.cursor).unwrap_or(snap.len()); let idx = snap.idx(snap.cursor).unwrap_or(snap.len());
let step = let step = Self::find_word_boundary(
Self::find_word_boundary(snap.value[idx..].chars(), opt.end_of_word, opt.end_of_word); snap.value[idx..].chars(),
// When in vim mode and deleting, we want to skip over the boundary of words.
// In other words |A|bcd efg when deleting till the end of the word should be
// | |efg as opposed to |d| efg.
if let InputOp::Delete(..) = snap.op { false } else { opt.end_of_word },
opt.end_of_word,
);
self.move_(step as isize) self.move_(step as isize)
} }
} }