forked from qt-creator/qt-creator
SyntaxHighlighter: Fix tst_highlighter
Change-Id: I96c6c7b9843384d14bfa37b6bfdd494c881949af Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -28,9 +28,10 @@ public:
|
||||
}
|
||||
|
||||
SyntaxHighlighterRunnerPrivate(BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator,
|
||||
QTextDocument *document)
|
||||
QTextDocument *document, FontSettings fontSettings)
|
||||
: m_creator(creator)
|
||||
, m_document(document)
|
||||
, m_fontSettings(fontSettings)
|
||||
{
|
||||
m_highlighter.reset(m_creator());
|
||||
createHighlighter();
|
||||
@@ -109,14 +110,16 @@ private:
|
||||
BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator m_creator;
|
||||
std::unique_ptr<SyntaxHighlighter> m_highlighter;
|
||||
QTextDocument *m_document = nullptr;
|
||||
const FontSettings m_fontSettings = TextEditorSettings::fontSettings();
|
||||
FontSettings m_fontSettings;
|
||||
};
|
||||
|
||||
// ----------------------------- BaseSyntaxHighlighterRunner --------------------------------------
|
||||
|
||||
BaseSyntaxHighlighterRunner::BaseSyntaxHighlighterRunner(
|
||||
BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator, QTextDocument *document)
|
||||
: d(new SyntaxHighlighterRunnerPrivate(creator, document))
|
||||
BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator,
|
||||
QTextDocument *document,
|
||||
const TextEditor::FontSettings &fontSettings)
|
||||
: d(new SyntaxHighlighterRunnerPrivate(creator, document, fontSettings))
|
||||
{
|
||||
m_document = document;
|
||||
}
|
||||
|
@@ -3,7 +3,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <texteditor/fontsettings.h>
|
||||
#include <texteditor/syntaxhighlighter.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
#include <KSyntaxHighlighting/Definition>
|
||||
|
||||
@@ -28,7 +30,10 @@ public:
|
||||
QString text;
|
||||
};
|
||||
|
||||
BaseSyntaxHighlighterRunner(SyntaxHighLighterCreator creator, QTextDocument *document);
|
||||
BaseSyntaxHighlighterRunner(SyntaxHighLighterCreator creator,
|
||||
QTextDocument *document,
|
||||
const TextEditor::FontSettings &fontSettings
|
||||
= TextEditorSettings::fontSettings());
|
||||
virtual ~BaseSyntaxHighlighterRunner();
|
||||
|
||||
void setExtraFormats(const QMap<int, QList<QTextLayout::FormatRange>> &formats);
|
||||
|
@@ -56,13 +56,11 @@ Second with spaces
|
||||
|
||||
Last)";
|
||||
|
||||
|
||||
doc = new QTextDocument();
|
||||
doc->setPlainText(text);
|
||||
|
||||
highlighterRunner
|
||||
= new BaseSyntaxHighlighterRunner([this] { return new SyntaxHighlighter(doc, fontsettings); },
|
||||
doc);
|
||||
highlighterRunner = new BaseSyntaxHighlighterRunner(
|
||||
[this] { return new SyntaxHighlighter(doc, fontsettings); }, doc, fontsettings);
|
||||
}
|
||||
|
||||
static const HighlightingResults &highlightingResults()
|
||||
|
Reference in New Issue
Block a user