[gtksourceview] gtksourceview: delete selection when indenting
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] gtksourceview: delete selection when indenting
- Date: Fri, 31 May 2019 19:33:23 +0000 (UTC)
commit 70a854a522fa6f2012bdd4a9722a6a0ab0e27095
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 46218f54..de136600 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -4089,8 +4089,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]