Unnamed repository; edit this file 'description' to name the repository.
Add changes for undo in insert mode (#11090)
* Add changes before insert mode undo
Fixes #11077
* Address edge cases for undo like Kakoune does
---------
Co-authored-by: Kaniel Kirby <[email protected]>
Co-authored-by: Michael Davis <[email protected]>
| -rw-r--r-- | helix-view/src/document.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index a56cbc2f..ccf2fa8c 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -1410,6 +1410,11 @@ impl Document { } fn undo_redo_impl(&mut self, view: &mut View, undo: bool) -> bool { + if undo { + self.append_changes_to_history(view); + } else if !self.changes.is_empty() { + return false; + } let mut history = self.history.take(); let txn = if undo { history.undo() } else { history.redo() }; let success = if let Some(txn) = txn { @@ -1490,6 +1495,11 @@ impl Document { } fn earlier_later_impl(&mut self, view: &mut View, uk: UndoKind, earlier: bool) -> bool { + if earlier { + self.append_changes_to_history(view); + } else if !self.changes.is_empty() { + return false; + } let txns = if earlier { self.history.get_mut().earlier(uk) } else { |