[gtksourceview/gtksourceview-4-2] gtksourceview: delete selection when indenting



commit ff78755f9bdc33532f50dfbc658ae8228b1e536c
Author: Christian Hergert <chergert redhat com>
Date:   Fri May 31 12:32:56 2019 -0700

    gtksourceview: delete selection when indenting
    
    When we auto-indent, we should delete the selected text just like we do
    when there is no auto-indent. However, we should still indent after that
    text is deleted.
    
    Fixes #60

 gtksourceview/gtksourceview.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 328fbb20..568be5f2 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -4026,8 +4026,14 @@ gtk_source_view_key_press_event (GtkWidget   *widget,
                                return GDK_EVENT_STOP;
                        }
 
-                       /* If an input method has inserted some text while handling the key press event,
-                        * the cur iterm may be invalid, so get the iter again */
+                       /* Delete any selected text to preserve behavior without auto-indent */
+                       gtk_text_buffer_delete_selection (buf,
+                                                         TRUE,
+                                                         gtk_text_view_get_editable (GTK_TEXT_VIEW (view)));
+
+                       /* If an input method or deletion has inserted some text while handling the
+                        * key press event, the cur iterm may be invalid, so get the iter again
+                        */
                        gtk_text_buffer_get_iter_at_mark (buf, &cur, mark);
 
                        /* Insert new line and auto-indent. */


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