QSyntaxHighlighter: cancel delayed highlight if done manually
It was an implicit effect before which stopped working after
dec7961709
. Reintroduce it as some
projects used this side-effect as a way to abort the initial
highlighting.
Change-Id: I5340ee9882a242bc8b5f7f843f1cfe793a65d357
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
This commit is contained in:
parent
fa2821b484
commit
f8f0f3eef1
@ -376,6 +376,7 @@ void QSyntaxHighlighter::rehighlight()
|
||||
|
||||
QTextCursor cursor(d->doc);
|
||||
d->rehighlight(cursor, QTextCursor::End);
|
||||
d->rehighlightPending = false; // user manually did a full rehighlight
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -82,6 +82,7 @@ private slots:
|
||||
void preservePreeditArea();
|
||||
void task108530();
|
||||
void avoidUnnecessaryRehighlight();
|
||||
void avoidUnnecessaryDelayedRehighlight();
|
||||
void noContentsChangedDuringHighlight();
|
||||
void rehighlight();
|
||||
void rehighlightBlock();
|
||||
@ -478,6 +479,24 @@ void tst_QSyntaxHighlighter::avoidUnnecessaryRehighlight()
|
||||
QTRY_VERIFY(!hl->highlighted);
|
||||
}
|
||||
|
||||
void tst_QSyntaxHighlighter::avoidUnnecessaryDelayedRehighlight()
|
||||
{
|
||||
// Having text in the document before creating the highlighter starts the delayed rehighlight
|
||||
cursor.insertText("Hello World");
|
||||
|
||||
TestHighlighter *hl = new TestHighlighter(doc);
|
||||
QVERIFY(!hl->highlighted);
|
||||
|
||||
hl->rehighlight();
|
||||
QVERIFY(hl->highlighted);
|
||||
|
||||
hl->highlighted = false;
|
||||
// Process events, including delayed rehighlight emission
|
||||
QCoreApplication::processEvents();
|
||||
// Should be cancelled and no extra rehighlight should be done
|
||||
QVERIFY(!hl->highlighted);
|
||||
}
|
||||
|
||||
void tst_QSyntaxHighlighter::noContentsChangedDuringHighlight()
|
||||
{
|
||||
QVector<QTextLayout::FormatRange> formats;
|
||||
|
Loading…
Reference in New Issue
Block a user