[evolution/gnome-3-30] I#103 - Extra new line added in front of long URLs



commit a1cd5d1332d29790e14a21687c91dfe10a9820cc
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 3 15:05:42 2018 +0200

    I#103 - Extra new line added in front of long URLs
    
    Closes https://gitlab.gnome.org/GNOME/evolution/issues/103

 src/e-util/test-html-editor-units-bugs.c           | 39 ++++++++++++++++++++++
 .../web-extension/e-editor-dom-functions.c         |  2 +-
 2 files changed, 40 insertions(+), 1 deletion(-)
---
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index f89565f7e2..e18f21a354 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -1322,6 +1322,44 @@ test_issue_86 (TestFixture *fixture)
        g_free (converted);
 }
 
+static void
+test_issue_103 (TestFixture *fixture)
+{
+       #define LONG_URL 
"https://www.example.com/123456789012345678901234567890123456789012345678901234567890";
+       #define SHORTER_URL "https://www.example.com/1234567890123456789012345678901234567890";
+       #define SHORT_URL "https://www.example.com/";
+
+       if (!test_utils_run_simple_test (fixture,
+               "mode:plain\n"
+               "type:before\\n"
+               LONG_URL "\\n"
+               "after\\n"
+               "prefix text " SHORTER_URL " suffix\\n"
+               "prefix " SHORT_URL " suffix\\n"
+               "end\n",
+               HTML_PREFIX "<div style=\"width: 71ch;\">before</div>"
+               "<div style=\"width: 71ch;\"><a href=\"" LONG_URL "\">" LONG_URL "</a></div>"
+               "<div style=\"width: 71ch;\">after</div>"
+               "<div style=\"width: 71ch;\">prefix text <a href=\"" SHORTER_URL "\">" SHORTER_URL "</a> 
suffix</div>"
+               "<div style=\"width: 71ch;\">prefix <a href=\"" SHORT_URL "\">" SHORT_URL "</a> suffix</div>"
+               "<div style=\"width: 71ch;\">end</div>"
+               HTML_SUFFIX,
+               "before\n"
+               LONG_URL "\n"
+               "after\n"
+               "prefix text \n"
+               SHORTER_URL " suffix\n"
+               "prefix " SHORT_URL " suffix\n"
+               "end")) {
+               g_test_fail ();
+               return;
+       }
+
+       #undef SHORT_URL
+       #undef SHORTER_URL
+       #undef LONG_URL
+}
+
 void
 test_add_html_editor_bug_tests (void)
 {
@@ -1352,4 +1390,5 @@ test_add_html_editor_bug_tests (void)
        test_utils_add_test ("/bug/788829", test_bug_788829);
        test_utils_add_test ("/bug/750636", test_bug_750636);
        test_utils_add_test ("/issue/86", test_issue_86);
+       test_utils_add_test ("/issue/103", test_issue_103);
 }
diff --git a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 71d80ae5a7..1d7beecdb7 100644
--- a/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/src/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -14139,7 +14139,7 @@ wrap_lines (EEditorPage *editor_page,
 
                                next_sibling = webkit_dom_node_get_next_sibling (node);
                                /* If the anchor doesn't fit on the line, add it to a separate line. */
-                               if ((line_length + anchor_length) > length_to_wrap) {
+                               if (line_length > 0 && (line_length + anchor_length) > length_to_wrap) {
                                        /* Put <BR> before the anchor, thus it starts on a new line */
                                        element = webkit_dom_document_create_element (document, "BR", NULL);
                                        element_add_class (element, "-x-evo-wrap-br");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]