Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82995

Nested text lits gets placed outside existing text list if it would be last element

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.14.1
    • GUI: Text handling
    • None
    • Qt 5.14.1

      Reproduced successfully on Windows 10 and Ubuntu 18.04 LTS
    • Linux/X11, Windows

    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.

      Attachments

        1. main.cpp
          2 kB
        2. repro.pro
          0.2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            avayert Ava Yert
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes