diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-08-08 16:18:19 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-08-08 16:18:19 +0000 |
commit | 9654fff6e02922fb241172daf2bd5ef468ad6af1 (patch) | |
tree | 85c095e2d8a3650a38934717407adc484d08028e /gtk/gtktextview.c | |
parent | 8725fd308baf67119da35a549541a8f999725256 (diff) | |
parent | a27c3039d0a20c6ec4e9fba1fe1b5437a65b834a (diff) | |
download | gtk+-9654fff6e02922fb241172daf2bd5ef468ad6af1.tar.gz |
Merge branch 'scroll-to-cursor' into 'master'
Scroll to cursor after canceling a selection
Closes #2960
See merge request GNOME/gtk!2321
Diffstat (limited to 'gtk/gtktextview.c')
-rw-r--r-- | gtk/gtktextview.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 806635b620..3b450dd552 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -6338,26 +6338,22 @@ gtk_text_view_move_cursor (GtkTextView *text_view, */ move_cursor (text_view, &newplace, extend_selection); - if (!gtk_text_iter_equal (&insert, &newplace)) - { - DV(g_print (G_STRLOC": scrolling onscreen\n")); - gtk_text_view_scroll_mark_onscreen (text_view, - gtk_text_buffer_get_insert (get_buffer (text_view))); + DV(g_print (G_STRLOC": scrolling onscreen\n")); + gtk_text_view_scroll_mark_onscreen (text_view, + gtk_text_buffer_get_insert (get_buffer (text_view))); - if (step == GTK_MOVEMENT_DISPLAY_LINES) - gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, -1); - } - else if (leave_direction != (GtkDirectionType)-1) + if (step == GTK_MOVEMENT_DISPLAY_LINES) + gtk_text_view_set_virtual_cursor_pos (text_view, cursor_x_pos, -1); + + if (gtk_text_iter_equal (&insert, &newplace)) { - if (!gtk_widget_keynav_failed (GTK_WIDGET (text_view), - leave_direction)) + if (leave_direction != (GtkDirectionType)-1) { - g_signal_emit_by_name (text_view, "move-focus", leave_direction); + if (!gtk_widget_keynav_failed (GTK_WIDGET (text_view), leave_direction)) + g_signal_emit_by_name (text_view, "move-focus", leave_direction); } - } - else if (! cancel_selection) - { - gtk_widget_error_bell (GTK_WIDGET (text_view)); + else if (!cancel_selection) + gtk_widget_error_bell (GTK_WIDGET (text_view)); } gtk_text_view_check_cursor_blink (text_view); |