@@ -751,19 +751,35 @@ impl Document {
751751 }
752752
753753 /// Undo modifications to the [`Document`] according to `uk`.
754− pub fn earlier(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) {
754+ pub fn earlier(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) -> bool {
755755 let txns = self.history.get_mut().earlier(uk);
756+ let mut success = false;
756757 for txn in txns {
757− self.apply_impl(&txn, view_id);
758+ if self.apply_impl(&txn, view_id) {
759+ success = true;
760+ }
761+ }
762+ if success {
763+ // reset changeset to fix len
764+ self.changes = ChangeSet::new(self.text());
758765 }
766+ success
759767 }
760768
761769 /// Redo modifications to the [`Document`] according to `uk`.
762− pub fn later(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) {
770+ pub fn later(&mut self, view_id: ViewId, uk: helix_core::history::UndoKind) -> bool {
763771 let txns = self.history.get_mut().later(uk);
772+ let mut success = false;
764773 for txn in txns {
765− self.apply_impl(&txn, view_id);
774+ if self.apply_impl(&txn, view_id) {
775+ success = true;
776+ }
777+ }
778+ if success {
779+ // reset changeset to fix len
780+ self.changes = ChangeSet::new(self.text());
766781 }
782+ success
767783 }
768784
769785 /// Commit pending changes to history