Commit 7a9d481a authored by Milan Crha's avatar Milan Crha

Bug 750636 - [Composer] Wrapped line should not start with a space

Closes https://bugzilla.gnome.org/show_bug.cgi?id=750636
parent 7d998f95
......@@ -1148,6 +1148,63 @@ test_bug_788829 (TestFixture *fixture)
g_test_fail ();
}
static void
test_bug_750636 (TestFixture *fixture)
{
test_utils_fixture_change_setting_int32 (fixture, "org.gnome.evolution.mail", "composer-word-wrap-length", 71);
if (!test_utils_run_simple_test (fixture,
"mode:plain\n"
"type:"
"12345678901234567890123456789012345678901234567890123456789012345678901"
"12345678901234567890123456789012345678901234567890123456789012345678901A\\n\\n"
"1234567890123456789012345678901234567890123456789012345678901234567890 B\\n\\n"
"12345678901234567890123456789012345678901234567890123456789012345678901 C\\n\\n"
"1234567890123456789012345678901234567890123456789012345678901234567890 D\\n\\n"
"12345678901234567890123456789012345678901234567890123456789012345678901" UNICODE_NBSP UNICODE_NBSP UNICODE_NBSP "E\\n\\n"
"1234567890123456789012345678901234567890123456789012345678901234567890" UNICODE_NBSP UNICODE_NBSP UNICODE_NBSP "F\\n\\n"
" 1\\n"
" 2\\n"
" 3\\n"
"\n",
HTML_PREFIX "<div style=\"width: 71ch;\">"
"12345678901234567890123456789012345678901234567890123456789012345678901"
"12345678901234567890123456789012345678901234567890123456789012345678901A</div>"
"<div style=\"width: 71ch;\"><br></div><div style=\"width: 71ch;\">"
"1234567890123456789012345678901234567890123456789012345678901234567890 B</div>"
"<div style=\"width: 71ch;\"><br></div><div style=\"width: 71ch;\">"
"12345678901234567890123456789012345678901234567890123456789012345678901 C</div>"
"<div style=\"width: 71ch;\"><br></div><div style=\"width: 71ch;\">"
"1234567890123456789012345678901234567890123456789012345678901234567890 D</div>"
"<div style=\"width: 71ch;\"><br></div><div style=\"width: 71ch;\">"
"12345678901234567890123456789012345678901234567890123456789012345678901&nbsp;&nbsp;&nbsp;E</div>"
"<div style=\"width: 71ch;\"><br></div><div style=\"width: 71ch;\">"
"1234567890123456789012345678901234567890123456789012345678901234567890&nbsp;&nbsp;&nbsp;F</div>"
"<div style=\"width: 71ch;\"><br></div>"
"<div style=\"width: 71ch;\"> 1</div>"
"<div style=\"width: 71ch;\"> 2</div>"
"<div style=\"width: 71ch;\"> 3</div>"
"<div style=\"width: 71ch;\"><br></div>"
HTML_SUFFIX,
"12345678901234567890123456789012345678901234567890123456789012345678901\n"
"12345678901234567890123456789012345678901234567890123456789012345678901\n"
"A\n\n"
"1234567890123456789012345678901234567890123456789012345678901234567890\n"
"B\n\n"
"12345678901234567890123456789012345678901234567890123456789012345678901\n"
"C\n\n"
"1234567890123456789012345678901234567890123456789012345678901234567890 \n"
"D\n\n"
"12345678901234567890123456789012345678901234567890123456789012345678901\n"
" E\n\n"
"1234567890123456789012345678901234567890123456789012345678901234567890 \n"
" F\n\n"
" 1\n"
" 2\n"
" 3\n"))
g_test_fail ();
}
void
test_add_html_editor_bug_tests (void)
{
......@@ -1176,4 +1233,5 @@ test_add_html_editor_bug_tests (void)
test_utils_add_test ("/bug/781116", test_bug_781116);
test_utils_add_test ("/bug/780088", test_bug_780088);
test_utils_add_test ("/bug/788829", test_bug_788829);
test_utils_add_test ("/bug/750636", test_bug_750636);
}
......@@ -14057,7 +14057,7 @@ wrap_lines (EEditorPage *editor_page,
element_has_class (WEBKIT_DOM_ELEMENT (sibling), "Apple-tab-span"))
tab_length = TAB_LENGTH;
else {
tab_length = TAB_LENGTH - (line_length + compensated ? 0 : (word_wrap_length - length_to_wrap)) % TAB_LENGTH;
tab_length = TAB_LENGTH - (line_length + (compensated ? 0 : (word_wrap_length - length_to_wrap))) % TAB_LENGTH;
compensated = TRUE;
}
......@@ -14227,16 +14227,26 @@ wrap_lines (EEditorPage *editor_page,
if ((nd = webkit_dom_node_get_next_sibling (prev_sibling))) {
gchar *nd_content;
nd_content = webkit_dom_node_get_text_content (nd);
if (nd_content && *nd_content) {
if (*nd_content == ' ')
mark_and_remove_leading_space (document, nd);
while (nd_content = webkit_dom_node_get_text_content (nd), nd_content) {
gboolean changed = FALSE;
if (!webkit_dom_node_get_next_sibling (nd) &&
g_str_has_suffix (nd_content, " "))
mark_and_remove_trailing_space (document, nd);
if (*nd_content) {
if (*nd_content == ' ') {
mark_and_remove_leading_space (document, nd);
changed = TRUE;
}
if (!webkit_dom_node_get_next_sibling (nd) &&
g_str_has_suffix (nd_content, " ")) {
mark_and_remove_trailing_space (document, nd);
changed = TRUE;
}
}
g_free (nd_content);
if (!changed)
break;
}
if (nd) {
......@@ -14288,19 +14298,28 @@ wrap_lines (EEditorPage *editor_page,
gboolean no_sibling = FALSE;
gchar *nd_content;
nd_content = webkit_dom_node_get_text_content (nd);
if (nd_content && *nd_content) {
if (*nd_content == ' ')
mark_and_remove_leading_space (document, nd);
if (!webkit_dom_node_get_next_sibling (nd) &&
length_left <= length_to_wrap &&
g_str_has_suffix (nd_content, " ")) {
mark_and_remove_trailing_space (document, nd);
no_sibling = TRUE;
while (nd_content = webkit_dom_node_get_text_content (nd), nd_content) {
gboolean changed = FALSE;
if (*nd_content) {
if (*nd_content == ' ') {
mark_and_remove_leading_space (document, nd);
changed = TRUE;
}
if (!webkit_dom_node_get_next_sibling (nd) &&
length_left <= length_to_wrap &&
g_str_has_suffix (nd_content, " ")) {
mark_and_remove_trailing_space (document, nd);
no_sibling = TRUE;
changed = TRUE;
}
}
g_free (nd_content);
if (!changed)
break;
}
if (!no_sibling)
......
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