Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.14.1
-
None
-
Qt 5.14.1
Reproduced successfully on Windows 10 and Ubuntu 18.04 LTS
Description
A QTextList inside an existing one has unexpected behaviour if an operation leaves the nested one as the last element.
Brief explanation and ways to reproduce
Attached in the bug report is the file main.cpp.
In the file, within a QTextEdit a QTextList is created. The resulting HTML (gotten from toHtml(), formatted and stripped of noisy metadata) results in the following:
<body> <ol> <li>Line one</li> <li>Line two</li> </ol> </body>
Placing the cursor before the L of Line two and calling textCursor().createList() (pressing F8 in attached script) leaves the newly created list below the existing one:
<body> <ol> <li>Line one</li> </ol> <ol> <li>Line two</li> </ol> </body>
instead of the expected
<body> <ol> <li>Line one</li> <ol> <li>Line two</li> </ol> </ol> </body>
Pressing the key F9 instead creates a new block with textCursor().insertBlock(), moves the cursor to the previous block, and then inserts the list. This produces the expected HTML:
<body> <ol> <li>Line one</li> <ol> <li> <br /> </li> </ol> <li>Line two</li> </ol> </body>
However, upon moving back the cursor to the block containing Line two, and inserting that block into the newly created list with new_list.add(cursor.block()) causes the newly created list to "jump" out of the existing one once again:
<body> <ol> <li>Line one</li> </ol> <ol> <li> <br /> </li> <li>Line two</li> </ol> </body>
I found no existing report of this bug, and could not find an explanation of whether or not this was intended behaviour.