[evolution] Bug 781722 - Switching citation in Reply to "Preformatted" duplicates citation marks



commit 5e659d0482a145964eab3bd3c0e15c97ead44a79
Author: Tomas Popela <tpopela redhat com>
Date:   Fri Apr 28 08:24:50 2017 +0200

    Bug 781722 - Switching citation in Reply to "Preformatted" duplicates citation marks
    
    The citation level needs to be counted for every block otherwise the
    block won't be quoted in the right way. Also use the simplified function
    for quoting as it is faster and reliable.

 src/e-util/test-html-editor-units-bugs.c           |   29 ++++++++++++++++++++
 .../web-extension/e-editor-dom-functions.c         |   20 +++++---------
 2 files changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index ee80d6d..984b211 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -952,6 +952,34 @@ test_bug_780275_plain (TestFixture *fixture)
                g_test_fail ();
 }
 
+static void
+test_bug_781722 (TestFixture *fixture)
+{
+       if (!test_utils_process_commands (fixture,
+               "mode:plain\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<pre>Signed-off-by: User &lt;<a href=\"mailto:user@no.where\";>user@no.where</a>&gt;\n"
+               "</pre><span class=\"-x-evo-to-body\" data-credits=\"Credits:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:dd\n"
+               "action:style-preformat\n",
+               HTML_PREFIX "<div style=\"width: 71ch;\">Credits:</div>"
+               "<blockquote type=\"cite\">"
+               "<pre>&gt; Signed-off-by: User &lt;<a 
href=\"mailto:user@no.where\";>user@no.where</a>&gt;</pre>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "Credits:\n"
+               "> Signed-off-by: User <user@no.where>"))
+               g_test_fail ();
+}
+
 void
 test_add_html_editor_bug_tests (void)
 {
@@ -976,4 +1004,5 @@ test_add_html_editor_bug_tests (void)
        test_utils_add_test ("/bug/779707", test_bug_779707);
        test_utils_add_test ("/bug/780275/html", test_bug_780275_html);
        test_utils_add_test ("/bug/780275/plain", test_bug_780275_plain);
+       test_utils_add_test ("/bug/781722", test_bug_781722);
 }
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 f73f432..1df2eed 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
@@ -16505,13 +16505,11 @@ process_block_to_block (EEditorPage *editor_page,
 
                remove_node (block);
 
-               if (!next_block && !after_selection_end) {
-                       citation_level = e_editor_dom_get_citation_level (WEBKIT_DOM_NODE (element), FALSE);
+               citation_level = e_editor_dom_get_citation_level (WEBKIT_DOM_NODE (element), FALSE);
 
-                       if (citation_level > 0) {
-                               next_block = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element));
-                               next_block = webkit_dom_node_get_next_sibling (next_block);
-                       }
+               if (!next_block && !after_selection_end && citation_level > 0) {
+                       next_block = webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (element));
+                       next_block = webkit_dom_node_get_next_sibling (next_block);
                }
 
                block = next_block;
@@ -16532,13 +16530,9 @@ process_block_to_block (EEditorPage *editor_page,
                        }
                }
 
-               if (!html_mode && quoted) {
-                       if (citation_level > 0)
-                               e_editor_dom_quote_plain_text_element_after_wrapping (
-                                       editor_page, element, citation_level);
-                       else
-                               e_editor_dom_quote_plain_text_element (editor_page, element);
-               }
+               if (!html_mode && quoted && citation_level > 0)
+                       e_editor_dom_quote_plain_text_element_after_wrapping (
+                               editor_page, element, citation_level);
        }
 
        return after_selection_end;


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