mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: restore original cursor on undoing
This commit is contained in:
parent
43e731b9a1
commit
0f76923a4d
2 changed files with 24 additions and 8 deletions
|
|
@ -97,19 +97,25 @@ impl Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn visual(&mut self) -> bool {
|
pub fn visual(&mut self) -> bool { self.snap_mut().visual() }
|
||||||
self.snap_mut().visual();
|
|
||||||
self.escape()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn undo(&mut self) -> bool {
|
pub fn undo(&mut self) -> bool {
|
||||||
self.snaps.undo();
|
if !self.snaps.undo() {
|
||||||
self.escape()
|
return false;
|
||||||
|
}
|
||||||
|
self.escape();
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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 {
|
pub fn move_(&mut self, step: isize) -> bool {
|
||||||
let snap = self.snap();
|
let snap = self.snap();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::mem;
|
||||||
|
|
||||||
use super::InputSnap;
|
use super::InputSnap;
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Eq)]
|
#[derive(Default, PartialEq, Eq)]
|
||||||
|
|
@ -37,7 +39,8 @@ impl InputSnaps {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn tag(&mut self) -> bool {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,6 +49,13 @@ impl InputSnaps {
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
true
|
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 {
|
impl InputSnaps {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue