From e092b32922ef650d49167aaf48f9d33190191f9f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 23 Apr 2019 07:48:50 +0200 Subject: [PATCH] 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 --- src/gui/text/qtextmarkdownimporter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index 6bff337ff40..2477e0bc74c 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(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)