From 258b89bb7077035bea1fec94ad6f9b8f165dc575 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 3 Nov 2021 09:44:23 +0100 Subject: [PATCH] Request autoscroll when undoing/redoing --- crates/editor/src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/lib.rs b/crates/editor/src/lib.rs index d41fbf81cbb5c1d91543e2b8b64729b75a566ce6..56f93eb5af88bc827b576936103aa178fa88903b 100644 --- a/crates/editor/src/lib.rs +++ b/crates/editor/src/lib.rs @@ -1527,10 +1527,12 @@ impl Editor { pub fn undo(&mut self, _: &Undo, cx: &mut ViewContext) { self.buffer.update(cx, |buffer, cx| buffer.undo(cx)); + self.request_autoscroll(cx); } pub fn redo(&mut self, _: &Redo, cx: &mut ViewContext) { self.buffer.update(cx, |buffer, cx| buffer.redo(cx)); + self.request_autoscroll(cx); } pub fn move_left(&mut self, _: &MoveLeft, cx: &mut ViewContext) { @@ -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.autoscroll_requested = true; + cx.notify(); + } + fn start_transaction(&self, cx: &mut ViewContext) { self.buffer.update(cx, |buffer, _| { buffer