From c0e17dd324f016401d56d66b7c113dada0644155 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Fri, 23 Oct 2020 11:32:25 +0900 Subject: Fix undo/redo not updating the syntax tree. --- helix-view/src/commands.rs | 8 ++++++-- helix-view/src/document.rs | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'helix-view/src') diff --git a/helix-view/src/commands.rs b/helix-view/src/commands.rs index b5350ff4..6bf89040 100644 --- a/helix-view/src/commands.rs +++ b/helix-view/src/commands.rs @@ -509,13 +509,17 @@ pub fn insert_char_prompt(prompt: &mut Prompt, c: char) { // Undo / Redo pub fn undo(view: &mut View, _count: usize) { - view.doc.history.undo(&mut view.doc.state); + if let Some(revert) = view.doc.history.undo() { + view.doc.apply(&revert); + } // TODO: each command could simply return a Option, then the higher level handles storing it? } pub fn redo(view: &mut View, _count: usize) { - view.doc.history.redo(&mut view.doc.state); + if let Some(transaction) = view.doc.history.redo() { + view.doc.apply(&transaction); + } } // Yank / Paste diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index c4b9d081..04018ed6 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -108,7 +108,6 @@ impl Document { }; } - // TODO: needs to run on undo/redo pub fn apply(&mut self, transaction: &Transaction) -> bool { let old_doc = self.text().clone(); -- cgit v1.2.3-70-g09d2