summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocument_p.cpp
diff options
context:
space:
mode:
authorSanthosh Kumar <[email protected]>2023-12-03 22:00:37 +0100
committerShawn Rutledge <[email protected]>2023-12-20 15:01:40 +0000
commit8a725084396da5872fa020212b3cb09ee40a91df (patch)
treeebd9c402cf152dceffbccb5e9597ff1166ccc239 /src/gui/text/qtextdocument_p.cpp
parent5b09d9e6d694045a6cef15f8984bab63cf86402c (diff)
Skip 'off-by-one' adjustment in block length during undo operation
The adjustment of block length with 'off-by-one' affects content length during undo operation. The issue occurs when we perform undo operation for a set of group blocks that have same fragment position. Since their positions are same, group block change (QTextDocumentPrivate::documentChange) with respect to insertion doesn't affect document block length and further adjustment to 'off-by-one' without considering this leads to incorrect document content change information (such as invalid information with regard to characters removed). This patch skips adjustment of group block length during undo operation. Amends 8fbedf2196a292fe2affcf83ddc846b9c852772a Fixes: QTBUG-113865 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I315dcf01ba5b2f4ed6d95e9d6910d82848374aef Reviewed-by: Shawn Rutledge <[email protected]>
Diffstat (limited to 'src/gui/text/qtextdocument_p.cpp')
-rw-r--r--src/gui/text/qtextdocument_p.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 0718300d375..3c1fc04d4b6 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -349,8 +349,10 @@ int QTextDocumentPrivate::insert_block(int pos, uint strPos, int format, int blo
QTextBlockGroup *group = qobject_cast<QTextBlockGroup *>(objectForFormat(blockFormat));
if (group) {
group->blockInserted(QTextBlock(this, b));
- docChangeOldLength--;
- docChangeLength--;
+ if (command != QTextUndoCommand::BlockDeleted) {
+ docChangeOldLength--;
+ docChangeLength--;
+ }
}
QTextFrame *frame = qobject_cast<QTextFrame *>(objectForFormat(formats.format(format)));