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>
This commit is contained in:
parent
03f7d0a005
commit
e092b32922
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user