[evolution] Bug 772171 - Editing quoted replies can break message content



commit 20cc9a7384b3ffc6a2f78054e08fd8ff98f5dac3
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Oct 3 13:44:05 2016 +0200

    Bug 772171 - Editing quoted replies can break message content
    
    Don't save the selection again in
    e_editor_dom_fix_structure_after_delete_before_quoted_content() as later
    the selection markers are not used to restore the selection, but they
    would prevent the delete operation to process correctly.
    
    Also restore the selection on other places when we are not using it
    anymore.

 e-util/test-html-editor-units-bugs.c               |   31 ++++++++++++++++++++
 .../web-extension/e-editor-dom-functions.c         |    4 ++-
 2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/e-util/test-html-editor-units-bugs.c b/e-util/test-html-editor-units-bugs.c
index 9e71bb0..b7dbfe3 100644
--- a/e-util/test-html-editor-units-bugs.c
+++ b/e-util/test-html-editor-units-bugs.c
@@ -669,6 +669,36 @@ test_bug_771493 (TestFixture *fixture)
                g_test_fail ();
 }
 
+static void
+test_bug_772171 (TestFixture *fixture)
+{
+       if (!test_utils_process_commands (fixture,
+               "mode:plain\n")) {
+               g_test_fail ();
+               return;
+       }
+
+       test_utils_insert_content (fixture,
+               "<body><pre>a\n"
+               "b\n"
+               "<span class=\"-x-evo-to-body\" data-credits=\"On Thu, 2016-09-15 at 08:08 -0400, user 
wrote:\"></span>"
+               "<span class=\"-x-evo-cite-body\"></span></body>",
+               E_CONTENT_EDITOR_INSERT_REPLACE_ALL | E_CONTENT_EDITOR_INSERT_TEXT_HTML);
+
+       if (!test_utils_run_simple_test (fixture,
+               "seq:deb",
+               HTML_PREFIX_PLAIN "<div style=\"width: 71ch;\">On Thu, 2016-09-15 at 08:08 -0400, user 
wrote:</div>"
+               "<blockquote type=\"cite\">"
+               "<div style=\"width: 71ch;\">&gt; <br></div>"
+               "<div style=\"width: 71ch;\">&gt; b</div>"
+               "</blockquote>"
+               HTML_SUFFIX,
+               "On Thu, 2016-09-15 at 08:08 -0400, user wrote:\n"
+               "> \n"
+               "> b"))
+               g_test_fail ();
+}
+
 void
 test_add_html_editor_bug_tests (void)
 {
@@ -684,4 +714,5 @@ test_add_html_editor_bug_tests (void)
        test_utils_add_test ("/bug/771044", test_bug_771044);
        test_utils_add_test ("/bug/771131", test_bug_771131);
        test_utils_add_test ("/bug/771493", test_bug_771493);
+       test_utils_add_test ("/bug/772171", test_bug_772171);
 }
diff --git a/modules/webkit-editor/web-extension/e-editor-dom-functions.c 
b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
index 31c8e93..fc58d41 100644
--- a/modules/webkit-editor/web-extension/e-editor-dom-functions.c
+++ b/modules/webkit-editor/web-extension/e-editor-dom-functions.c
@@ -9099,6 +9099,7 @@ save_history_for_delete_or_backspace (EEditorPage *editor_page,
                        g_clear_object (&range_clone);
                        g_clear_object (&dom_selection);
                        g_warning ("History event was not saved for %s key", delete_key ? "Delete" : 
"Backspace");
+                       e_editor_dom_selection_restore (editor_page);
                        return;
                }
 
@@ -9324,6 +9325,8 @@ save_history_for_delete_or_backspace (EEditorPage *editor_page,
 
        manager = e_editor_page_get_undo_redo_manager (editor_page);
        e_editor_undo_redo_manager_insert_history_event (manager, ev);
+
+       e_editor_dom_selection_restore (editor_page);
 }
 
 gboolean
@@ -9377,7 +9380,6 @@ e_editor_dom_fix_structure_after_delete_before_quoted_content (EEditorPage *edit
                                e_editor_dom_selection_restore (editor_page);
                                save_history_for_delete_or_backspace (
                                        editor_page, key_code == HTML_KEY_CODE_DELETE, control_key);
-                               e_editor_dom_selection_save (editor_page);
                        }
 
                        /* Remove the empty block and move caret to the right place. */


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