summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2019-04-23 07:48:50 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2019-04-27 21:59:15 +0000
commite092b32922ef650d49167aaf48f9d33190191f9f (patch)
tree832d5a691df019cb3e8de8fe8f82fd00ed1843a3 /src/gui
parent03f7d0a005eca7c796c8721a8bec860e320f4219 (diff)
QTextMarkdownImporter: insert list items into the correct list
There was a bug when handling situations like 1. first 1) subfirst 2. second It was always inserting items into the list where the cursor already was, but it needs to insert the "second" list item into the list which is currently the top of m_listStack. Change-Id: Id0899032efafb2e2b9e7c45a6fb9f2c5221fc4df Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index 6bff337ff4..2477e0bc74 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -165,13 +165,14 @@ int QTextMarkdownImporter::cbEnterBlock(MD_BLOCKTYPE type, void *det)
} break;
case MD_BLOCK_LI: {
MD_BLOCK_LI_DETAIL *detail = static_cast<MD_BLOCK_LI_DETAIL *>(det);
- QTextBlockFormat bfmt = m_cursor->blockFormat();
+ QTextList *list = m_listStack.top();
+ QTextBlockFormat bfmt = list->item(list->count() - 1).blockFormat();
bfmt.setMarker(detail->is_task ?
(detail->task_mark == ' ' ? QTextBlockFormat::Unchecked : QTextBlockFormat::Checked) :
QTextBlockFormat::NoMarker);
if (!m_emptyList) {
m_cursor->insertBlock(bfmt, QTextCharFormat());
- m_listStack.top()->add(m_cursor->block());
+ list->add(m_cursor->block());
}
m_cursor->setBlockFormat(bfmt);
m_emptyList = false; // Avoid insertBlock for the first item (because insertList already did that)