TextEditor: add tests for semantic highlighter

Change-Id: Id64c933f01c0dbc0e077656b6f4260b93e124311
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-05-16 14:57:37 +02:00
parent 31090ded15
commit f235a72554
9 changed files with 365 additions and 1 deletions

View File

@@ -23,8 +23,12 @@ class SyntaxHighlighterPrivate
Q_DECLARE_PUBLIC(SyntaxHighlighter)
public:
SyntaxHighlighterPrivate()
: SyntaxHighlighterPrivate(TextEditorSettings::fontSettings())
{ }
SyntaxHighlighterPrivate(const FontSettings &fontSettings)
{
updateFormats(TextEditorSettings::fontSettings());
updateFormats(fontSettings);
}
QPointer<QTextDocument> doc;
@@ -76,6 +80,16 @@ void SyntaxHighlighter::delayedRehighlight()
rehighlight();
}
#ifdef WITH_TESTS
SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent, const FontSettings &fontsettings)
: QObject(parent), d_ptr(new SyntaxHighlighterPrivate(fontsettings))
{
d_ptr->q_ptr = this;
if (parent)
setDocument(parent);
}
#endif
void SyntaxHighlighterPrivate::applyFormatChanges(int from, int charsRemoved, int charsAdded)
{
bool formatsChanged = false;