From 5c7bbe2e59304bb63b84f7ce26e588d58c6f4a06 Mon Sep 17 00:00:00 2001 From: Francis Chua Date: Sun, 12 Nov 2023 16:39:15 +0000 Subject: [PATCH] special case deleting to end of word in vim --- yazi-core/src/input/commands/forward.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/yazi-core/src/input/commands/forward.rs b/yazi-core/src/input/commands/forward.rs index 52970be0..87185521 100644 --- a/yazi-core/src/input/commands/forward.rs +++ b/yazi-core/src/input/commands/forward.rs @@ -1,6 +1,6 @@ use yazi_config::keymap::Exec; -use crate::input::Input; +use crate::input::{op::InputOp, Input}; pub struct Opt { end_of_word: bool, @@ -20,8 +20,14 @@ impl Input { let snap = self.snap(); let idx = snap.idx(snap.cursor).unwrap_or(snap.len()); - let step = - Self::find_word_boundary(snap.value[idx..].chars(), opt.end_of_word, opt.end_of_word); + let step = Self::find_word_boundary( + 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) } }