[evolution] I#1344 - Composer: Paragraph format change misbehaves on empty paragraph



commit 99c485049b54d228517da548b812ac4e5a99b04c
Author: Milan Crha <mcrha redhat com>
Date:   Wed Feb 24 12:25:48 2021 +0100

    I#1344 - Composer: Paragraph format change misbehaves on empty paragraph
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1344

 data/webkit/e-editor.js                  |  7 +++++--
 src/e-util/test-html-editor-units-bugs.c | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/data/webkit/e-editor.js b/data/webkit/e-editor.js
index 6d34d7dda6..74ba6f413a 100644
--- a/data/webkit/e-editor.js
+++ b/data/webkit/e-editor.js
@@ -595,7 +595,7 @@ EvoEditor.ClaimAffectedContent = function(startNode, endNode, flags)
        var commonParent, startChild, endChild;
        var firstChildIndex = -1, html = "", ii;
        var withHtml = (flags & EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML) != 0;
-       var currentElemsArray = null;
+       var currentElemsArray = null, fromSelection = false;
 
        if (!startNode) {
                startNode = document.getSelection().anchorNode;
@@ -604,6 +604,8 @@ EvoEditor.ClaimAffectedContent = function(startNode, endNode, flags)
                if (!startNode) {
                        startNode = document.body;
                }
+
+               fromSelection = true;
        }
 
        if (!endNode) {
@@ -613,7 +615,8 @@ EvoEditor.ClaimAffectedContent = function(startNode, endNode, flags)
                        endNode = startNode;
        }
 
-       if ((flags & EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE) != 0) {
+       if ((flags & EvoEditor.CLAIM_CONTENT_FLAG_USE_PARENT_BLOCK_NODE) != 0 && (
+           !fromSelection || !EvoEditor.IsBlockNode(startNode))) {
                if (startNode && !(startNode === document.body)) {
                        startNode = startNode.parentElement;
                }
diff --git a/src/e-util/test-html-editor-units-bugs.c b/src/e-util/test-html-editor-units-bugs.c
index 2ffef09876..b30c7944c4 100644
--- a/src/e-util/test-html-editor-units-bugs.c
+++ b/src/e-util/test-html-editor-units-bugs.c
@@ -2304,6 +2304,30 @@ test_issue_1365 (TestFixture *fixture)
                g_test_fail ();
 }
 
+static void
+test_issue_1344 (TestFixture *fixture)
+{
+       if (!test_utils_run_simple_test (fixture,
+               "mode:plain\n"
+               "type:\\n\\na\\nb\\n\n"
+               "seq:Chcd\n"
+               "action:style-list-bullet\n"
+               "type:c\n",
+               HTML_PREFIX
+               "<div style=\"width: 71ch;\"><br></div>"
+               "<ul style=\"width: 68ch;\"><li>c</li></ul>"
+               "<div style=\"width: 71ch;\">a</div>"
+               "<div style=\"width: 71ch;\">b</div>"
+               "<div style=\"width: 71ch;\"><br></div>"
+               HTML_SUFFIX,
+               "\n"
+               " * c\n"
+               "a\n"
+               "b\n"
+               "\n"))
+               g_test_fail ();
+}
+
 void
 test_add_html_editor_bug_tests (void)
 {
@@ -2344,4 +2368,5 @@ test_add_html_editor_bug_tests (void)
        test_utils_add_test ("/issue/1330", test_issue_1330);
        test_utils_add_test ("/issue/1157", test_issue_1157);
        test_utils_add_test ("/issue/1365", test_issue_1365);
+       test_utils_add_test ("/issue/1344", test_issue_1344);
 }


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