on master help sign in
Fix undo redo

I missed the fast return. Fix #89

commite6132f0acdee8bfa542cd7f7571aeae702ac21a8 authorIvan Tham <pickfire@riseup.net> dateThu 3 Jun 2021, 23:10 (5 years ago) parent3071339
1 file changed+17−11
helix-view/src/document.rs+17−11
helix-view/src/document.rs+17−11
@@ -342,29 +342,35 @@ impl Document {
342342
343343 pub fn undo(&mut self, view_id: ViewId) -> bool {
344344 let mut history = self.history.take();
345− if let Some(transaction) = history.undo() {
346− let success = self._apply(&transaction, view_id);
345+ let success = if let Some(transaction) = history.undo() {
346+ self._apply(&transaction, view_id)
347+ } else {
348+ false
349+ };
350+ self.history.set(history);
347351
352+ if success {
348353 // reset changeset to fix len
349354 self.changes = ChangeSet::new(self.text());
350−
351− return success;
352355 }
353− self.history.set(history);
354− false
356+
357+ success
355358 }
356359
357360 pub fn redo(&mut self, view_id: ViewId) -> bool {
358361 let mut history = self.history.take();
359− if let Some(transaction) = history.redo() {
360− let success = self._apply(&transaction, view_id);
362+ let success = if let Some(transaction) = history.redo() {
363+ self._apply(&transaction, view_id)
364+ } else {
365+ false
366+ };
367+ self.history.set(history);
361368
369+ if success {
362370 // reset changeset to fix len
363371 self.changes = ChangeSet::new(self.text());
364−
365− return success;
366372 }
367− self.history.set(history);
373+
368374 false
369375 }
370376