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

[reg 6.3.2 -> 6.5.1] TextEdit wrong wrapping with wrapMode: TextEdit.Wrap in some cases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.1, 6.5.2, 6.7.3
    • None
    • Qt 6.3.2, 6.5.1
      macOS 13.4.1

    Description

      TextEdit with textFormat: TextEdit.RichText, white-space:pre-wrap (this is required, because RichText collapses whitespaces by default), wrapMode: Text.Wrap - fails to break text into lines when text exceeds width.

      This is a regression since 6.3.2.
      I was able to reproduce it only with specific conditions - a combination of some spaces (U+0020) and tab (U+0009).
      The long line of spaces is not wrapped (this has changed since 6.3.2, as can be seen on screenshots), and it's kind of expected with white-space:pre-wrap (or not? spaces should be preserved, but probably wrapped also, as regular text)
      Spaces alone do not break the wrapping of the rest of text, but once you add a tab, the text wrapping is not working anymore. And this is a regression since 6.3.2. Text wrapping should respect TextEdit's width.

      6.3.2

      6.5.1

      Sample code:

      import QtQuick
      import QtQuick.Window
      import QtQuick.Layouts
      
      Window {
          width: 640
          height: 480
          visible: true
      
          ColumnLayout {
              id: layout
              x: 20
              y: 20
              width: 200
      
              TextEdit {
                  id: text
                  Layout.fillWidth: true
                  readonly property string _spaces: '                                                                       '
                  readonly property string _tab: '	'
                  readonly property string _part: 'NoWhitespaceNoWhitespace(<a href="https://doc.qt.io/qt-6/qml-qtquick-textedit.html" style="color:#2b95f0;text-underline-style:solid;">NoSpacesHere</a>)'
                  readonly property string _br: '<br>'
                  readonly property string _text: _spaces + _tab + _part + _part + _br + _part + _br
                  text: '<span style="white-space:pre-wrap">' + _text + '</span>'
                  wrapMode: Text.Wrap
                  textFormat: TextEdit.RichText
      
      
                  Rectangle { // to show geometry of TextEdit
                      anchors.fill: parent
                      color: Qt.rgba(0,0,0,0.2)
                  }
              }
          }
      }
      

      ( main.qml )

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            sergei.nevdakh Sergei Nevdakh
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes