@@ -834,11 +834,11 @@ impl Document {
834834 success
835835 }
836836
837− fn undo_redo_impl(&mut self, view_id: ViewId, undo: bool) -> bool {
837+ fn undo_redo_impl(&mut self, view: &mut View, undo: bool) -> bool {
838838 let mut history = self.history.take();
839839 let txn = if undo { history.undo() } else { history.redo() };
840840 let success = if let Some(txn) = txn {
841− self.apply_impl(txn, view_id)
841+ self.apply_impl(txn, view.id) && view.apply(txn, self)
842842 } else {
843843 false
844844 };
@@ -852,13 +852,13 @@ impl Document {
852852 }
853853
854854 /// Undo the last modification to the [`Document`]. Returns whether the undo was successful.
855− pub fn undo(&mut self, view_id: ViewId) -> bool {
856− self.undo_redo_impl(view_id, true)
855+ pub fn undo(&mut self, view: &mut View) -> bool {
856+ self.undo_redo_impl(view, true)
857857 }
858858
859859 /// Redo the last modification to the [`Document`]. Returns whether the redo was successful.
860− pub fn redo(&mut self, view_id: ViewId) -> bool {
861− self.undo_redo_impl(view_id, false)
860+ pub fn redo(&mut self, view: &mut View) -> bool {
861+ self.undo_redo_impl(view, false)
862862 }
863863
864864 pub fn savepoint(&mut self) {
@@ -871,7 +871,7 @@ impl Document {
871871 }
872872 }
873873
874− fn earlier_later_impl(&mut self, view_id: ViewId, uk: UndoKind, earlier: bool) -> bool {
874+ fn earlier_later_impl(&mut self, view: &mut View, uk: UndoKind, earlier: bool) -> bool {
875875 let txns = if earlier {
876876 self.history.get_mut().earlier(uk)
877877 } else {
@@ -879,7 +879,7 @@ impl Document {
879879 };
880880 let mut success = false;
881881 for txn in txns {
882− if self.apply_impl(&txn, view_id) {
882+ if self.apply_impl(&txn, view.id) && view.apply(&txn, self) {
883883 success = true;
884884 }
885885 }
@@ -891,13 +891,13 @@ impl Document {
891891 }
892892
893893 /// Undo modifications to the [`Document`] according to `uk`.
894− pub fn earlier(&mut self, view_id: ViewId, uk: UndoKind) -> bool {
895− self.earlier_later_impl(view_id, uk, true)
894+ pub fn earlier(&mut self, view: &mut View, uk: UndoKind) -> bool {
895+ self.earlier_later_impl(view, uk, true)
896896 }
897897
898898 /// Redo modifications to the [`Document`] according to `uk`.
899− pub fn later(&mut self, view_id: ViewId, uk: UndoKind) -> bool {
900− self.earlier_later_impl(view_id, uk, false)
899+ pub fn later(&mut self, view: &mut View, uk: UndoKind) -> bool {
900+ self.earlier_later_impl(view, uk, false)
901901 }
902902
903903 /// Commit pending changes to history