mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-11-10 06:16:00 +03:00
parent
d131a9dd0e
commit
9d591427be
@ -1845,7 +1845,10 @@ mod cmd {
|
||||
.map_err(|s| anyhow!(s))?;
|
||||
|
||||
let (view, doc) = current!(cx.editor);
|
||||
doc.earlier(view.id, uk);
|
||||
let success = doc.earlier(view.id, uk);
|
||||
if !success {
|
||||
cx.editor.set_status("Already at oldest change".to_owned());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -1860,7 +1863,10 @@ mod cmd {
|
||||
.parse::<helix_core::history::UndoKind>()
|
||||
.map_err(|s| anyhow!(s))?;
|
||||
let (view, doc) = current!(cx.editor);
|
||||
doc.later(view.id, uk);
|
||||
let success = doc.later(view.id, uk);
|
||||
if !success {
|
||||
cx.editor.set_status("Already at newest change".to_owned());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -751,20 +751,36 @@ impl Document {
|
||||
}
|
||||
|
||||
/// Undo modifications to the [`Document`] according to `uk`.
|
||||
pub fn earlier(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) {
|
||||
pub fn earlier(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) -> bool {
|
||||
let txns = self.history.get_mut().earlier(uk);
|
||||
let mut success = false;
|
||||
for txn in txns {
|
||||
self.apply_impl(&txn, view_id);
|
||||
if self.apply_impl(&txn, view_id) {
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
if success {
|
||||
// reset changeset to fix len
|
||||
self.changes = ChangeSet::new(self.text());
|
||||
}
|
||||
success
|
||||
}
|
||||
|
||||
/// Redo modifications to the [`Document`] according to `uk`.
|
||||
pub fn later(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) {
|
||||
pub fn later(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) -> bool {
|
||||
let txns = self.history.get_mut().later(uk);
|
||||
let mut success = false;
|
||||
for txn in txns {
|
||||
self.apply_impl(&txn, view_id);
|
||||
if self.apply_impl(&txn, view_id) {
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
if success {
|
||||
// reset changeset to fix len
|
||||
self.changes = ChangeSet::new(self.text());
|
||||
}
|
||||
success
|
||||
}
|
||||
|
||||
/// Commit pending changes to history
|
||||
pub fn append_changes_to_history(&mut self, view_id: ViewId) {
|
||||
|
Loading…
Reference in New Issue
Block a user