summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2018-11-06 12:08:05 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2018-11-08 16:38:27 +0000
commitdec7961709c90f6977d2447f7fa6c6625af41cb2 (patch)
tree2b5a6c33fd369b3b0ea5192e8b1c3df0bfda44a1 /tests/auto
parentbdebc90c2826866e4434a6429aa6f822ee3cb8f6 (diff)
QSyntaxHighlighter: Delay all highlights until first rehighlight
When calling setDocument (directly or through the constructor) a delayed rehighlight is initiated. Previously, if any text was changed before this rehighlight could run it would cancel the rehighlight, even if the changed text only caused a new block of text to be highlighted. Fixes: QTBUG-71307 Change-Id: Ib09b664d90906f5b4427105f0e45469806f3a779 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
index 0a2e024701..9d6ce78b24 100644
--- a/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
+++ b/tests/auto/gui/text/qsyntaxhighlighter/tst_qsyntaxhighlighter.cpp
@@ -74,6 +74,7 @@ private slots:
void emptyBlocks();
void setCharFormat();
void highlightOnInit();
+ void highlightOnInitAndAppend();
void stopHighlightingWhenStateDoesNotChange();
void unindent();
void highlightToEndOfDocument();
@@ -265,6 +266,19 @@ void tst_QSyntaxHighlighter::highlightOnInit()
QTRY_VERIFY(hl->highlighted);
}
+void tst_QSyntaxHighlighter::highlightOnInitAndAppend()
+{
+ cursor.insertText("Hello");
+ cursor.insertBlock();
+ cursor.insertText("World");
+
+ TestHighlighter *hl = new TestHighlighter(doc);
+ cursor.insertBlock();
+ cursor.insertText("More text");
+ QTRY_VERIFY(hl->highlighted);
+ QVERIFY(hl->highlightedText.endsWith(doc->toPlainText().remove(QLatin1Char('\n'))));
+}
+
class StateTestHighlighter : public QSyntaxHighlighter
{
public:
@@ -330,6 +344,7 @@ void tst_QSyntaxHighlighter::unindent()
QCOMPARE(doc->toPlainText(), plainText);
TestHighlighter *hl = new TestHighlighter(doc);
+ QTRY_VERIFY(hl->highlighted);
hl->callCount = 0;
cursor.movePosition(QTextCursor::Start);