Evas Textblock: Don't convert <br/> to <ps/> after changing text

Summary:
It was only happened when legacy newline is enabled. By default,
legacy newline is enabled. As I know, legacy newline option has
to change textblock's internal behavior. But, it shouldn't change
the given original text. It fixes T3399.

Test Plan: A Test case is included in Evas test suite.

Reviewers: Jaehyun_Cho, z-wony, tasn, woohyun, herdsman, Blackmole, devilhorns

Subscribers: #committers, zmike, raster, cedric, jpeg

Tags: #efl

Maniphest Tasks: T3399

Differential Revision: https://phab.enlightenment.org/D3874
This commit is contained in:
Youngbok Shin 2018-07-02 16:17:33 +03:00 committed by Daniel Hirt
parent 6d6f943acd
commit f6acd6f9e4
2 changed files with 16 additions and 1 deletions

View File

@ -10836,7 +10836,7 @@ _evas_textblock_cursor_format_append(Efl_Text_Cursor_Cursor *cur,
Eina_Unicode insert_char;
/* Insert a visual representation according to the type of the
format */
if (_IS_PARAGRAPH_SEPARATOR(o, format))
if (_IS_PARAGRAPH_SEPARATOR_SIMPLE(format))
insert_char = _PARAGRAPH_SEPARATOR;
else if (_IS_LINE_SEPARATOR(format))
insert_char = _NEWLINE;

View File

@ -2977,6 +2977,21 @@ EFL_START_TEST(evas_textblock_editing)
evas_textblock_cursor_paragraph_first(cur);
fail_if(evas_textblock_cursor_paragraph_next(cur));
/* Test cursor range delete with <br/> tags when legacy newline is enabled.
* After deleting first <br/> tag, the second <br/> tag shouldn't be changed to <ps/> */
evas_object_textblock_legacy_newline_set(tb, EINA_TRUE);
evas_object_textblock_text_markup_set(tb, "A<br/><br/>B");
evas_textblock_cursor_paragraph_first(cur);
evas_textblock_cursor_paragraph_first(main_cur);
evas_textblock_cursor_pos_set(main_cur, 2);
ck_assert_str_eq(evas_textblock_cursor_range_text_get(cur, main_cur, EVAS_TEXTBLOCK_TEXT_MARKUP), "A<br/>");
evas_textblock_cursor_range_delete(cur, main_cur);
ck_assert_str_eq(evas_object_textblock_text_markup_get(tb), "<br/>B");
/* Restore legacy newline disabled setting */
evas_object_textblock_legacy_newline_set(tb, EINA_FALSE);
{
/* Limit to 1000 iterations so we'll never get into an infinite loop,
* even if broken */