fix: panic caused by incorrect offset reset

This commit is contained in:
sxyazi 2023-11-15 23:38:04 +08:00
parent 0ea9bcda5f
commit 027c7a79c1
No known key found for this signature in database
2 changed files with 7 additions and 5 deletions

View file

@ -39,7 +39,7 @@ impl Input {
);
let snap = self.snap_mut();
if snap.cursor < snap.offset {
if snap.offset > snap.cursor {
snap.offset = snap.cursor;
} else if snap.value.is_empty() {
snap.offset = 0;

View file

@ -55,11 +55,13 @@ impl Input {
std::ops::Bound::Excluded(_) => unreachable!(),
std::ops::Bound::Unbounded => 0,
};
if snap.value.drain(range).next().is_some() {
self.flush_value();
return true;
if snap.value.drain(range).next().is_none() {
return false;
}
false
self.move_(0);
self.flush_value();
true
}
fn backspace(&mut self, under: bool) -> bool {