forked from enlightenment/efl
Evas/Textblock: Introduce PS deletion bug test and fix
Summary: This test should make the test suite fail. It sets "a<ps>b" and "a<ps/>b" markups, and deletes the PS format. Essentially, these two different markups should have the same result by this deletion. Instead, only the <ps/> format gets deleted properly. A follow-up commit is added with this as a fix. Evas/Textblock: fix deletion of PS bug Fixes an issue with deletion of "<ps>". Format deletion was only performed for formats that are own-closers. This sets the paragraph separator to be an own-closer format. @fix Reviewers: tasn Reviewed By: tasn CC: JackDanielZ, id213sin Differential Revision: https://phab.enlightenment.org/D1046
This commit is contained in:
parent
ac63e3f8b5
commit
2b40860f78
|
@ -8491,11 +8491,27 @@ _evas_textblock_node_format_new(Evas_Textblock_Data *o, const char *_format)
|
|||
if ((format_len > 0) && format[format_len - 1] == '>')
|
||||
{
|
||||
format_len--; /* We don't care about '>' */
|
||||
/* Check if it closes itself. Skip the </> case. */
|
||||
if ((format_len > 1) && format[format_len - 1] == '/')
|
||||
/* Check if it closes itself, i.e. one of the following:
|
||||
* 1. Ends with a "/" e.g. "<my_tag/>"
|
||||
* 2. Is a paragraph separator */
|
||||
/* Skip the </> case. */
|
||||
if (format_len > 1)
|
||||
{
|
||||
format_len--; /* We don't care about '/' */
|
||||
n->own_closer = EINA_TRUE;
|
||||
if (format[format_len - 1] == '/')
|
||||
{
|
||||
format_len--; /* We don't care about '/' */
|
||||
n->own_closer = EINA_TRUE;
|
||||
}
|
||||
else if (format_len == 2)
|
||||
{
|
||||
char tmp[format_len + 1];
|
||||
strncpy(tmp, format, format_len);
|
||||
tmp[format_len] = '\0';
|
||||
if (_IS_PARAGRAPH_SEPARATOR(o, tmp))
|
||||
{
|
||||
n->own_closer = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2909,6 +2909,42 @@ START_TEST(evas_textblock_size)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(evas_textblock_delete)
|
||||
{
|
||||
START_TB_TEST();
|
||||
const Evas_Object_Textblock_Node_Format *fmt;
|
||||
|
||||
/* The first and the second set of commands should result in the same
|
||||
* conditions for format and text nodes of the textblock object.
|
||||
* Essentially, it creates the markup 'a<ps>b' */
|
||||
evas_object_textblock_text_markup_set(tb, "ab");
|
||||
fmt = evas_textblock_cursor_format_get(cur);
|
||||
fail_if(fmt);
|
||||
evas_textblock_cursor_pos_set(cur, 1);
|
||||
evas_object_textblock_text_markup_prepend(cur, "<ps/>");
|
||||
evas_textblock_cursor_pos_set(cur, 1);
|
||||
fmt = evas_textblock_cursor_format_get(cur);
|
||||
fail_if (!fmt);
|
||||
evas_textblock_cursor_char_delete(cur);
|
||||
fmt = evas_textblock_cursor_format_get(cur);
|
||||
fail_if(fmt);
|
||||
|
||||
evas_object_textblock_text_markup_set(tb, "ab");
|
||||
fmt = evas_textblock_cursor_format_get(cur);
|
||||
fail_if(fmt);
|
||||
evas_textblock_cursor_pos_set(cur, 1);
|
||||
evas_object_textblock_text_markup_prepend(cur, "<ps>");
|
||||
evas_textblock_cursor_pos_set(cur, 1);
|
||||
fmt = evas_textblock_cursor_format_get(cur);
|
||||
fail_if (!fmt);
|
||||
evas_textblock_cursor_char_delete(cur);
|
||||
fmt = evas_textblock_cursor_format_get(cur);
|
||||
fail_if(fmt);
|
||||
|
||||
END_TB_TEST();
|
||||
}
|
||||
END_TEST;
|
||||
|
||||
void evas_test_textblock(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, evas_textblock_simple);
|
||||
|
@ -2929,5 +2965,6 @@ void evas_test_textblock(TCase *tc)
|
|||
tcase_add_test(tc, evas_textblock_various);
|
||||
tcase_add_test(tc, evas_textblock_wrapping);
|
||||
tcase_add_test(tc, evas_textblock_items);
|
||||
tcase_add_test(tc, evas_textblock_delete);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue