diff --git a/sw/qa/filter/md/md.cxx b/sw/qa/filter/md/md.cxx index bce9fcec503a..d4066fbdbca3 100644 --- a/sw/qa/filter/md/md.cxx +++ b/sw/qa/filter/md/md.cxx @@ -1068,6 +1068,15 @@ CPPUNIT_TEST_FIXTURE(Test, testListPaste) // i.e. pasting a list item at the end of a list item joined the two. CPPUNIT_ASSERT_EQUAL(u"List A"_ustr, getParagraph(2)->getString()); CPPUNIT_ASSERT_EQUAL(u"List 1"_ustr, getParagraph(3)->getString()); + + // And make sure the pasted list doesn't leave a trailing empty bullet + // between "List 2" and the pre-existing "List B" list item: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: List 2 + // - Actual : + // i.e. paragraph 4 was an empty. + CPPUNIT_ASSERT_EQUAL(u"List 2"_ustr, getParagraph(4)->getString()); + CPPUNIT_ASSERT_EQUAL(u"List B"_ustr, getParagraph(5)->getString()); } CPPUNIT_TEST_FIXTURE(Test, testCTLPaste) diff --git a/sw/source/filter/md/swmd.cxx b/sw/source/filter/md/swmd.cxx index 35083df1e771..8aad950b2bae 100644 --- a/sw/source/filter/md/swmd.cxx +++ b/sw/source/filter/md/swmd.cxx @@ -889,6 +889,19 @@ ErrCodeMsg MarkdownReader::Read(SwDoc& rDoc, const OUString& rBaseURL, SwPaM& rP if (m_bInsertMode) { + if (aPasteInfo.m_bStartAtEndOfPara) + { + // If the paste created an empty paragraph at the end, join that empty node with the + // previous one here. + SwNodeIndex aLast(*aPasteInfo.m_pSttNdIdx2, -1); + if (aLast.GetIndex() > aPasteInfo.m_pSttNdIdx->GetIndex() + 1) + { + SwTextNode* pLast = aLast.GetNode().GetTextNode(); + if (pLast && pLast->GetText().isEmpty()) + pLast->JoinPrev(); + } + } + EndPaste(aPasteInfo); }