mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: panic caused by incorrect offset reset
This commit is contained in:
parent
0ea9bcda5f
commit
027c7a79c1
2 changed files with 7 additions and 5 deletions
|
|
@ -39,7 +39,7 @@ impl Input {
|
||||||
);
|
);
|
||||||
|
|
||||||
let snap = self.snap_mut();
|
let snap = self.snap_mut();
|
||||||
if snap.cursor < snap.offset {
|
if snap.offset > snap.cursor {
|
||||||
snap.offset = snap.cursor;
|
snap.offset = snap.cursor;
|
||||||
} else if snap.value.is_empty() {
|
} else if snap.value.is_empty() {
|
||||||
snap.offset = 0;
|
snap.offset = 0;
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,13 @@ impl Input {
|
||||||
std::ops::Bound::Excluded(_) => unreachable!(),
|
std::ops::Bound::Excluded(_) => unreachable!(),
|
||||||
std::ops::Bound::Unbounded => 0,
|
std::ops::Bound::Unbounded => 0,
|
||||||
};
|
};
|
||||||
if snap.value.drain(range).next().is_some() {
|
if snap.value.drain(range).next().is_none() {
|
||||||
self.flush_value();
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
false
|
|
||||||
|
self.move_(0);
|
||||||
|
self.flush_value();
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn backspace(&mut self, under: bool) -> bool {
|
fn backspace(&mut self, under: bool) -> bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue