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

Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1344
This commit is contained in:
Milan Crha
2021-02-24 12:25:48 +01:00
parent 4c71e5fee4
commit 99c485049b
2 changed files with 30 additions and 2 deletions

View File

@ -595,7 +595,7 @@ EvoEditor.ClaimAffectedContent = function(startNode, endNode, flags)
var commonParent, startChild, endChild; var commonParent, startChild, endChild;
var firstChildIndex = -1, html = "", ii; var firstChildIndex = -1, html = "", ii;
var withHtml = (flags & EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML) != 0; var withHtml = (flags & EvoEditor.CLAIM_CONTENT_FLAG_SAVE_HTML) != 0;
var currentElemsArray = null; var currentElemsArray = null, fromSelection = false;
if (!startNode) { if (!startNode) {
startNode = document.getSelection().anchorNode; startNode = document.getSelection().anchorNode;
@ -604,6 +604,8 @@ EvoEditor.ClaimAffectedContent = function(startNode, endNode, flags)
if (!startNode) { if (!startNode) {
startNode = document.body; startNode = document.body;
} }
fromSelection = true;
} }
if (!endNode) { if (!endNode) {
@ -613,7 +615,8 @@ EvoEditor.ClaimAffectedContent = function(startNode, endNode, flags)
endNode = startNode; 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)) { if (startNode && !(startNode === document.body)) {
startNode = startNode.parentElement; startNode = startNode.parentElement;
} }

View File

@ -2304,6 +2304,30 @@ test_issue_1365 (TestFixture *fixture)
g_test_fail (); 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 void
test_add_html_editor_bug_tests (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/1330", test_issue_1330);
test_utils_add_test ("/issue/1157", test_issue_1157); test_utils_add_test ("/issue/1157", test_issue_1157);
test_utils_add_test ("/issue/1365", test_issue_1365); test_utils_add_test ("/issue/1365", test_issue_1365);
test_utils_add_test ("/issue/1344", test_issue_1344);
} }