Priority: P2: Important
Affects Version/s: 5.14.1
Component/s: GUI: Text handling
Commits:8fbedf2196a292fe2affcf83ddc846b9c852772a (qt/qtbase/dev) 2d51988904d9b117fe0fb0b9fd2ac666a61cd973 (qt/qtbase/6.2)
QTextDocument internally makes use of hidden or non visual characters (e.g. QTBUG-80662 - ) but the API's for accessing a modifying a QTextDocument (so either the limited API of QTextDocument itself or QTextCursor) do not consistently reflect the data that is exposed.
QTextDocument::contentsChange(int position,int removed,int added) includes character counts which take into account at least some of the hidden characters used internally, e.g. ones used to mark lists. QTextCursor does not take these extra characters into account and so it is possible for contentsChange to emit values which according to QTextCursor cannot exist (see attached example).
A simpler example of this is as reported in QTBUG-80662 - where QTextCursor and QTextDocument report different document lengths (QTextCursor does not include the extra hidden character).
Because the numbers do not line up, it is not possible to accurately detect and act upon small localized changes to the document. This makes things like shadow documents (helpful for collaborative text document merges for example) or simple synchronization of multiple QTextDocument instances (to workaround QQuickTextEdit limitations for example) is not possible without wiping and recreating the whole document on each change.
|For Gerrit Dashboard: QTBUG-82455|
|297709,1||QTextDocument: fix an off-by-one in the changed signal for lists||5.15||qt/qtbase||Status: ABANDONED||-1||0|
|383208,3||QTextDocument: fix an off-by-one in the changed signal for lists||dev||qt/qtbase||Status: MERGED||+2||0|
|383631,2||QTextDocument: fix an off-by-one in the changed signal for lists||6.2||qt/qtbase||Status: MERGED||+2||0|
|383634,3||QTextDocument: fix an off-by-one in the changed signal for lists||tqtc/lts-5.15||qt/tqtc-qtbase||Status: MERGED||+2||0|