[gtk/wip/chergert/4575-fix-texthistory-selection: 4/4] textview: scroll insert onscreen after undo/redo




commit 344ad0355efa35f80b3c4a597e91a5fe3f438eed
Author: Christian Hergert <chergert redhat com>
Date:   Sun Dec 26 12:56:42 2021 -0800

    textview: scroll insert onscreen after undo/redo
    
    After performing an action such as undo/redo, we need to actually scroll
    to the position where the operation occurred.
    
    I do note that the scroll here seems to often get invalidated if it is
    pages away, and we never make the full scroll. But I've seen this all over
    the place elsewhere too and that needs to be handled, most likely, as a
    more comprehensive fix for scrolling during line validation.
    
    Related #4575

 gtk/gtktextview.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index f8e1f0d1ed..00b361f8a2 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -10101,7 +10101,11 @@ gtk_text_view_real_undo (GtkWidget   *widget,
   GtkTextView *text_view = GTK_TEXT_VIEW (widget);
 
   if (gtk_text_view_get_editable (text_view))
-    gtk_text_buffer_undo (text_view->priv->buffer);
+    {
+      gtk_text_buffer_undo (text_view->priv->buffer);
+      gtk_text_view_scroll_mark_onscreen (text_view,
+                                          gtk_text_buffer_get_insert (text_view->priv->buffer));
+    }
 }
 
 static void
@@ -10112,7 +10116,11 @@ gtk_text_view_real_redo (GtkWidget   *widget,
   GtkTextView *text_view = GTK_TEXT_VIEW (widget);
 
   if (gtk_text_view_get_editable (text_view))
-    gtk_text_buffer_redo (text_view->priv->buffer);
+    {
+      gtk_text_buffer_redo (text_view->priv->buffer);
+      gtk_text_view_scroll_mark_onscreen (text_view,
+                                          gtk_text_buffer_get_insert (text_view->priv->buffer));
+    }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]