on master help sign in
Fix undo redo
e6132f0Ivan Tham
helix-view/src/document.rs+17−11
@@ -342,29 +342,35 @@ impl Document {
342
342
343 pub fn undo(&mut self, view_id: ViewId) -> bool {
343 pub fn undo(&mut self, view_id: ViewId) -> bool {
344 let mut history = self.history.take();
344 let mut history = self.history.take();
345− if let Some(transaction) = history.undo() {
345+ let success = if let Some(transaction) = history.undo() {
346− let success = self._apply(&transaction, view_id);
346+ self._apply(&transaction, view_id)
347+ } else {
348+ false
349+ };
350+ self.history.set(history);
347
351
352+ if success {
348 // reset changeset to fix len
353 // reset changeset to fix len
349 self.changes = ChangeSet::new(self.text());
354 self.changes = ChangeSet::new(self.text());
350−
351− return success;
352 }
355 }
353− self.history.set(history);
356+
354− false
357+ success
355 }
358 }
356
359
357 pub fn redo(&mut self, view_id: ViewId) -> bool {
360 pub fn redo(&mut self, view_id: ViewId) -> bool {
358 let mut history = self.history.take();
361 let mut history = self.history.take();
359− if let Some(transaction) = history.redo() {
362+ let success = if let Some(transaction) = history.redo() {
360− let success = self._apply(&transaction, view_id);
363+ self._apply(&transaction, view_id)
364+ } else {
365+ false
366+ };
367+ self.history.set(history);
361
368
369+ if success {
362 // reset changeset to fix len
370 // reset changeset to fix len
363 self.changes = ChangeSet::new(self.text());
371 self.changes = ChangeSet::new(self.text());
364−
365− return success;
366 }
372 }
367− self.history.set(history);
373+
368 false
374 false
369 }
375 }
370
376