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

QTextLayout selections doesn't work correctly with trailing spaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.2.1
    • GUI: Text handling
    • None
    • Windows 7, VS 2010

    Description

      When drawing a line contains only spaces and has any selections using QTextLayout::draw(), no selection is shown.

      To solve this problem, I've corrected QTextLayout and QTextEngine as following.

      • QTextLayout.cpp / line 1088
        original code : int sl_length = sl.length + (isLastLineInBlock? 1 : 0); // the infamous newline
        modified code : int sl_length = sl.length + sl.trailingSpaces + (isLastLineInBlock? 1 : 0); // the infamous newline
      • QTextLayout.cpp / line 1097
        original : if (sl.length && (selectionStartInLine || selectionEndInLine)) {
        modified : if (sl_length && (selectionStartInLine || selectionEndInLine)) {
      • QTextEngine.cpp / line 3484
        original : lineEnd(line.from + line.length),
        modified : lineEnd(line.from + line.length + line.trailingSpaces),

      Of course I know I may not consider all cases, but I think that above codes can help error correction.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            qrgscor RiJong
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes