From 8b4560cbfbc30f6db90455e2e5cd588bbb1db701 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 26 Jun 2020 15:27:09 -0400 Subject: [PATCH] Revert "text: Avoid creating a PangoAttrList we don't need" This reverts commit 67c26650280ba64ff1c0318be8d848e9563ddb21. The splicing we do here has the important side-effect of shifting the preedit attributes to the right position. Without it, we end up always underlining the first chars in the entry, regardless where the preedit happens. --- gtk/gtktext.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 2e4484c1f6..67400607a9 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -4354,6 +4354,8 @@ gtk_text_create_layout (GtkText *self, tmp_attrs = gtk_css_style_get_pango_attributes (gtk_css_node_get_style (gtk_widget_get_css_node (widget))); tmp_attrs = _gtk_pango_attr_list_merge (tmp_attrs, priv->attrs); + if (!tmp_attrs) + tmp_attrs = pango_attr_list_new (); display_text = gtk_text_get_display_text (self, 0, -1); @@ -4374,10 +4376,7 @@ gtk_text_create_layout (GtkText *self, pos = g_utf8_offset_to_pointer (display_text, priv->current_pos) - display_text; g_string_insert (tmp_string, pos, preedit_string); pango_layout_set_text (layout, tmp_string->str, tmp_string->len); - if (tmp_attrs) - pango_attr_list_splice (tmp_attrs, preedit_attrs, pos, preedit_length); - else - tmp_attrs = pango_attr_list_ref (preedit_attrs); + pango_attr_list_splice (tmp_attrs, preedit_attrs, pos, preedit_length); g_string_free (tmp_string, TRUE); } else