Fix scrollbar updates in QPlaintTextEdit on block-visibility changes

Trigger documentSizeChanged when block visibility changes, since block
count remains constant in this case.

Task-number: QTBUG-69310
Change-Id: I5ec7a4f9008f26ea8602356bcbaefbda293e54a3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
bb10
Allan Sandfeld Jensen 2018-09-26 11:59:32 +02:00
parent 0ead3b7142
commit 5fe2ed48d6
1 changed files with 7 additions and 2 deletions

View File

@ -294,6 +294,7 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c
QTextBlock changeStartBlock = doc->findBlock(from);
QTextBlock changeEndBlock = doc->findBlock(qMax(0, from + charsChanged - 1));
bool blockVisibilityChanged = false;
if (changeStartBlock == changeEndBlock && newBlockCount == d->blockCount) {
QTextBlock block = changeStartBlock;
@ -311,14 +312,18 @@ void QPlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int c
QTextBlock block = changeStartBlock;
do {
block.clearLayout();
const int lineCount = block.isVisible() ? 1 : 0;
if (block.lineCount() != lineCount) {
blockVisibilityChanged = true;
block.setLineCount(lineCount);
}
if (block == changeEndBlock)
break;
block = block.next();
} while(block.isValid());
}
if (newBlockCount != d->blockCount) {
if (newBlockCount != d->blockCount || blockVisibilityChanged) {
int changeEnd = changeEndBlock.blockNumber();
int blockDiff = newBlockCount - d->blockCount;
int oldChangeEnd = changeEnd - blockDiff;