mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix: panic replacing character in empty input
This commit is contained in:
parent
14f3ca55d2
commit
053426a489
1 changed files with 7 additions and 1 deletions
|
|
@ -17,8 +17,14 @@ impl Input {
|
|||
pub fn replace_str(&mut self, s: &str) {
|
||||
let snap = self.snap_mut();
|
||||
|
||||
if snap.value.is_empty() {
|
||||
snap.mode = InputMode::Normal;
|
||||
render!();
|
||||
return;
|
||||
}
|
||||
|
||||
let start = snap.idx(snap.cursor).unwrap();
|
||||
let end = snap.idx(snap.cursor + 1).unwrap(); // FIXME: panic if the input is empty while in replace mode
|
||||
let end = snap.idx(snap.cursor + 1).unwrap();
|
||||
|
||||
snap.mode = InputMode::Normal;
|
||||
snap.value.replace_range(start..end, s);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue