aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Tham2021-06-03 15:10:31 +0000
committerBlaž Hrastnik2021-06-03 16:27:09 +0000
commite6132f0acdee8bfa542cd7f7571aeae702ac21a8 (patch)
treee5c207b2743bd7bc8d320bb2a08faed27bf8bbf0
parent3071339cbcd197bbf8b5e66a97589103ddb1de5b (diff)
Fix undo redo
I missed the fast return. Fix #89
-rw-r--r--helix-view/src/document.rs28
1 files changed, 17 insertions, 11 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 3a3b9390..cf4a6faa 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -342,29 +342,35 @@ impl Document {
pub fn undo(&mut self, view_id: ViewId) -> bool {
let mut history = self.history.take();
- if let Some(transaction) = history.undo() {
- let success = self._apply(&transaction, view_id);
+ let success = if let Some(transaction) = history.undo() {
+ self._apply(&transaction, view_id)
+ } else {
+ false
+ };
+ self.history.set(history);
+ if success {
// reset changeset to fix len
self.changes = ChangeSet::new(self.text());
-
- return success;
}
- self.history.set(history);
- false
+
+ success
}
pub fn redo(&mut self, view_id: ViewId) -> bool {
let mut history = self.history.take();
- if let Some(transaction) = history.redo() {
- let success = self._apply(&transaction, view_id);
+ let success = if let Some(transaction) = history.redo() {
+ self._apply(&transaction, view_id)
+ } else {
+ false
+ };
+ self.history.set(history);
+ if success {
// reset changeset to fix len
self.changes = ChangeSet::new(self.text());
-
- return success;
}
- self.history.set(history);
+
false
}