Commit b61969be authored by mae's avatar mae
Browse files

Fix repaint issue with collapsed blocks

BaseTextEdit's paint event relied on us setting the line count of
invisible blocks to 0. This was not always the case, causing pixel
garbage to occur.
parent 51f997d6
...@@ -2209,9 +2209,14 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) ...@@ -2209,9 +2209,14 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
QTextBlock nextBlock = block.next(); QTextBlock nextBlock = block.next();
QTextBlock nextVisibleBlock = nextBlock; QTextBlock nextVisibleBlock = nextBlock;
if (!nextVisibleBlock.isVisible()) if (!nextVisibleBlock.isVisible()) {
// invisible blocks do have zero line count // invisible blocks do have zero line count
nextVisibleBlock = doc->findBlockByLineNumber(nextVisibleBlock.firstLineNumber()); nextVisibleBlock = doc->findBlockByLineNumber(nextVisibleBlock.firstLineNumber());
// paranoia in case our code somewhere did not set the line count
// of the invisible block to 0
while (nextVisibleBlock.isValid() && !nextVisibleBlock.isVisible())
nextVisibleBlock = nextVisibleBlock.next();
}
if (block.isVisible() && bottom >= e->rect().top()) { if (block.isVisible() && bottom >= e->rect().top()) {
if (d->m_displaySettings.m_visualizeWhitespace) { if (d->m_displaySettings.m_visualizeWhitespace) {
QTextLayout *layout = block.layout(); QTextLayout *layout = block.layout();
...@@ -2330,6 +2335,7 @@ void BaseTextEditor::paintEvent(QPaintEvent *e) ...@@ -2330,6 +2335,7 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
blockHeight += r.height(); blockHeight += r.height();
b.setVisible(false); // restore previous state b.setVisible(false); // restore previous state
b.setLineCount(0); // restore 0 line count for invisible block
b = b.next(); b = b.next();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment