mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41: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();
|
let snap = self.snaps.current_mut();
|
||||||
if !opt.under && snap.cursor < 1 {
|
if !opt.under && snap.cursor < 1 {
|
||||||
return;
|
return;
|
||||||
} else if opt.under && snap.cursor >= snap.value.len() {
|
} else if opt.under && snap.cursor >= snap.count() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ impl Input {
|
||||||
return;
|
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;
|
snap.value = new;
|
||||||
|
|
||||||
self.move_(delta);
|
self.move_(delta);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ impl InputSnap {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(super) fn reset(&mut self, limit: usize) {
|
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 =
|
||||||
self.offset.min(self.cursor.saturating_sub(Self::find_window(&self.rev(), 0, limit).end));
|
self.offset.min(self.cursor.saturating_sub(Self::find_window(&self.rev(), 0, limit).end));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue