mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-19 23:01:36 +03:00
feat: restore original cursor on undoing
This commit is contained in:
parent
43e731b9a1
commit
0f76923a4d
@ -97,19 +97,25 @@ impl Input {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn visual(&mut self) -> bool {
|
||||
self.snap_mut().visual();
|
||||
self.escape()
|
||||
}
|
||||
pub fn visual(&mut self) -> bool { self.snap_mut().visual() }
|
||||
|
||||
#[inline]
|
||||
pub fn undo(&mut self) -> bool {
|
||||
self.snaps.undo();
|
||||
self.escape()
|
||||
if !self.snaps.undo() {
|
||||
return false;
|
||||
}
|
||||
self.escape();
|
||||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn redo(&mut self) -> bool { self.snaps.redo() }
|
||||
pub fn redo(&mut self) -> bool {
|
||||
if !self.snaps.redo() {
|
||||
return false;
|
||||
}
|
||||
self.escape();
|
||||
true
|
||||
}
|
||||
|
||||
pub fn move_(&mut self, step: isize) -> bool {
|
||||
let snap = self.snap();
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::mem;
|
||||
|
||||
use super::InputSnap;
|
||||
|
||||
#[derive(Default, PartialEq, Eq)]
|
||||
@ -37,7 +39,8 @@ impl InputSnaps {
|
||||
}
|
||||
|
||||
pub(super) fn tag(&mut self) -> bool {
|
||||
if self.current.value == self.versions[self.idx].value {
|
||||
self.catch();
|
||||
if self.versions[self.idx].value == self.current.value {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -46,6 +49,13 @@ impl InputSnaps {
|
||||
self.idx += 1;
|
||||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(super) fn catch(&mut self) {
|
||||
let value = mem::replace(&mut self.versions[self.idx].value, String::new());
|
||||
self.versions[self.idx] = self.current.clone();
|
||||
self.versions[self.idx].value = value;
|
||||
}
|
||||
}
|
||||
|
||||
impl InputSnaps {
|
||||
|
Loading…
Reference in New Issue
Block a user