@@ -834,11 +834,11 @@ impl Document {
834
834
success
835
835
}
836
836
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 {
838
838
let mut history = self . history . take ( ) ;
839
839
let txn = if undo { history. undo ( ) } else { history. redo ( ) } ;
840
840
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 )
842
842
} else {
843
843
false
844
844
} ;
@@ -852,13 +852,13 @@ impl Document {
852
852
}
853
853
854
854
/// 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 )
857
857
}
858
858
859
859
/// 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 )
862
862
}
863
863
864
864
pub fn savepoint ( & mut self ) {
@@ -871,15 +871,15 @@ impl Document {
871
871
}
872
872
}
873
873
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 {
875
875
let txns = if earlier {
876
876
self . history . get_mut ( ) . earlier ( uk)
877
877
} else {
878
878
self . history . get_mut ( ) . later ( uk)
879
879
} ;
880
880
let mut success = false ;
881
881
for txn in txns {
882
- if self . apply_impl ( & txn, view_id ) {
882
+ if self . apply_impl ( & txn, view . id ) && view . apply ( & txn , self ) {
883
883
success = true ;
884
884
}
885
885
}
@@ -891,13 +891,13 @@ impl Document {
891
891
}
892
892
893
893
/// 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 )
896
896
}
897
897
898
898
/// 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 )
901
901
}
902
902
903
903
/// Commit pending changes to history
0 commit comments