Commit 8f3df20f authored by Christian Hergert's avatar Christian Hergert

xml-pack: fix element insertion in presence of >

Now that we auto insert matching <>, we need to make sure we
don't insert a second >.
parent 198da3f8
Pipeline #16257 passed with stage
in 17 minutes and 8 seconds
......@@ -324,20 +324,16 @@ ide_xml_indenter_maybe_add_closing (IdeXmlIndenter *xml,
copy = *begin;
if (gtk_text_iter_backward_search (&copy, "<", GTK_TEXT_SEARCH_TEXT_ONLY,
&match_begin, &match_end, NULL))
if (gtk_text_iter_backward_search (&copy, "<", GTK_TEXT_SEARCH_TEXT_ONLY, &match_begin, &match_end, NULL))
{
gchar *text;
g_autofree gchar *text = NULL;
/* avoid closing elements on spurious > */
gtk_text_iter_backward_char (&copy);
text = gtk_text_iter_get_slice (&match_begin, &copy);
if (strchr (text, '>'))
{
g_free (text);
return NULL;
}
g_free (text);
return NULL;
gtk_text_iter_forward_char (&match_begin);
if (gtk_text_iter_get_char (&match_begin) == '/')
......@@ -354,7 +350,10 @@ ide_xml_indenter_maybe_add_closing (IdeXmlIndenter *xml,
if (slice && *slice && *slice != '!')
{
ret = g_strdup_printf ("</%s>", slice);
if (gtk_text_iter_get_char (end) == '>')
ret = g_strdup_printf ("</%s", slice);
else
ret = g_strdup_printf ("</%s>", slice);
*cursor_offset = -strlen (ret);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment