From: Matthias Clasen Date: Sat, 22 Jul 2023 13:40:17 +0000 (-0400) Subject: textview: Match entry behavior for backspace X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~45^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9929726eb2abbb874ce6c83c7d9ee5b5bbcb8f28;p=gtk4.git textview: Match entry behavior for backspace As pointed out in #3417, there is a long-standing difference in how GtkEntry and GtkTextView treat Ctrl-Shift-Backspace (and other variations): GtkEntry always operates on the selection first, if it exists. GtkTextView only handled plain Backspace that way, and ignores the selection for other variations. There is no good reason for this difference, so just remove it and make GtkTextView behave the same as GtkEntry. Fixes: #3417 --- diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index b0a68f8504..961ceb4963 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -6885,16 +6885,13 @@ gtk_text_view_delete_from_cursor (GtkTextView *text_view, priv = text_view->priv; - if (type == GTK_DELETE_CHARS) + /* If a selection exists, we operate on it first */ + if (gtk_text_buffer_delete_selection (get_buffer (text_view), TRUE, + priv->editable)) { - /* Char delete deletes the selection, if one exists */ - if (gtk_text_buffer_delete_selection (get_buffer (text_view), TRUE, - priv->editable)) - { - priv->need_im_reset = TRUE; - gtk_text_view_reset_im_context (text_view); - return; - } + priv->need_im_reset = TRUE; + gtk_text_view_reset_im_context (text_view); + return; } gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,