Request autoscroll when undoing/redoing

Antonio Scandurra created

Change summary

crates/editor/src/lib.rs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

Detailed changes

crates/editor/src/lib.rs 🔗

@@ -1527,10 +1527,12 @@ impl Editor {
 
     pub fn undo(&mut self, _: &Undo, cx: &mut ViewContext<Self>) {
         self.buffer.update(cx, |buffer, cx| buffer.undo(cx));
+        self.request_autoscroll(cx);
     }
 
     pub fn redo(&mut self, _: &Redo, cx: &mut ViewContext<Self>) {
         self.buffer.update(cx, |buffer, cx| buffer.redo(cx));
+        self.request_autoscroll(cx);
     }
 
     pub fn move_left(&mut self, _: &MoveLeft, cx: &mut ViewContext<Self>) {
@@ -2344,10 +2346,8 @@ impl Editor {
         }
 
         if autoscroll {
-            self.autoscroll_requested = true;
-            cx.notify();
+            self.request_autoscroll(cx);
         }
-
         self.pause_cursor_blinking(cx);
 
         self.buffer.update(cx, |buffer, cx| {
@@ -2357,6 +2357,11 @@ impl Editor {
         });
     }
 
+    fn request_autoscroll(&mut self, cx: &mut ViewContext<Self>) {
+        self.autoscroll_requested = true;
+        cx.notify();
+    }
+
     fn start_transaction(&self, cx: &mut ViewContext<Self>) {
         self.buffer.update(cx, |buffer, _| {
             buffer