From fd311fb8ad8792c8f21ed0bcf56d4a818715d5f7 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Sun, 4 Oct 2020 17:15:43 +0900 Subject: Undo tree draft. We keep a tree of transactions. This allows for persistent undo by simply serializing the changesets. --- helix-view/src/commands.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'helix-view/src/commands.rs') diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs index 18135f0f..c92b33f5 100644 --- a/helix-view/src/commands.rs +++ b/helix-view/src/commands.rs @@ -417,3 +417,15 @@ pub fn delete_char_forward(view: &mut View, count: usize) { transaction.apply(&mut view.state); // TODO: need to store into history if successful } + +// Undo / Redo + +pub fn undo(view: &mut View, _count: usize) { + view.history.undo(&mut view.state); + + // TODO: each command should simply return a Option, then the higher level handles storing it? +} + +pub fn redo(view: &mut View, _count: usize) { + view.history.redo(&mut view.state); +} -- cgit v1.2.3-70-g09d2