mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
fix: backspace --under didn't map UTF-8 character code points to byte indices (#2010)
This commit is contained in:
parent
8ec944dbd3
commit
6308873f0b
3 changed files with 3 additions and 3 deletions
|
|
@ -20,7 +20,7 @@ impl Input {
|
|||
let snap = self.snaps.current_mut();
|
||||
if !opt.under && snap.cursor < 1 {
|
||||
return;
|
||||
} else if opt.under && snap.cursor >= snap.value.len() {
|
||||
} else if opt.under && snap.cursor >= snap.count() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl Input {
|
|||
return;
|
||||
}
|
||||
|
||||
let delta = new.chars().count() as isize - snap.value.chars().count() as isize;
|
||||
let delta = new.chars().count() as isize - snap.count() as isize;
|
||||
snap.value = new;
|
||||
|
||||
self.move_(delta);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ impl InputSnap {
|
|||
|
||||
#[inline]
|
||||
pub(super) fn reset(&mut self, limit: usize) {
|
||||
self.cursor = self.cursor.min(self.value.chars().count().saturating_sub(self.mode.delta()));
|
||||
self.cursor = self.cursor.min(self.count().saturating_sub(self.mode.delta()));
|
||||
self.offset =
|
||||
self.offset.min(self.cursor.saturating_sub(Self::find_window(&self.rev(), 0, limit).end));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue