From ee8b8fc730184c1452efafbb02b6477870f71ef5 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Mon, 15 Jan 2024 16:47:44 +0800 Subject: [PATCH] fix: support unicode characters in `kill` command --- yazi-core/src/input/commands/kill.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/yazi-core/src/input/commands/kill.rs b/yazi-core/src/input/commands/kill.rs index db1af71c..1e1b2fa0 100644 --- a/yazi-core/src/input/commands/kill.rs +++ b/yazi-core/src/input/commands/kill.rs @@ -62,8 +62,9 @@ impl Input { input.take_while(|&c| CharKind::new(c) == first).count() + 1 } - let spaces = count_spaces(input.clone()); - spaces + count_characters(input.skip(spaces)) + let n = count_spaces(input.clone()); + let n = n + count_characters(input.clone().skip(n)); + input.take(n).fold(0, |acc, c| acc + c.len_utf8()) } pub fn kill<'a>(&mut self, opt: impl Into>) {