diff --git a/src/plugins/cppeditor/cppcompletion_test.cpp b/src/plugins/cppeditor/cppcompletion_test.cpp index 738eaa08367..cf8b163ab4e 100644 --- a/src/plugins/cppeditor/cppcompletion_test.cpp +++ b/src/plugins/cppeditor/cppcompletion_test.cpp @@ -150,7 +150,7 @@ public: return true; return ::CppEditor::Tests::waitForSignalOrTimeout( cppEditor->textDocument()->syntaxHighlighterRunner(), - &BaseSyntaxHighlighterRunner::highlightingFinished, + &SyntaxHighlighterRunner::highlightingFinished, 5000); } diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp index d1297b1dd38..badd02b751b 100644 --- a/src/plugins/cppeditor/cppeditordocument.cpp +++ b/src/plugins/cppeditor/cppeditordocument.cpp @@ -164,7 +164,7 @@ QByteArray CppEditorDocument::contentsText() const void CppEditorDocument::applyFontSettings() { - if (TextEditor::BaseSyntaxHighlighterRunner *highlighter = syntaxHighlighterRunner()) + if (TextEditor::SyntaxHighlighterRunner *highlighter = syntaxHighlighterRunner()) highlighter->clearAllExtraFormats(); // Clear all additional formats since they may have changed TextDocument::applyFontSettings(); // rehighlights and updates additional formats if (m_processor) @@ -408,7 +408,7 @@ BaseEditorDocumentProcessor *CppEditorDocument::processor() connect(m_processor.data(), &BaseEditorDocumentProcessor::cppDocumentUpdated, this, [this](const CPlusPlus::Document::Ptr document) { // Update syntax highlighter - if (BaseSyntaxHighlighterRunner *highlighter = syntaxHighlighterRunner()) + if (SyntaxHighlighterRunner *highlighter = syntaxHighlighterRunner()) highlighter->setLanguageFeaturesFlags(document->languageFeatures().flags); m_overviewModel.update(usesClangd() ? nullptr : document); diff --git a/src/plugins/cppeditor/semantichighlighter.cpp b/src/plugins/cppeditor/semantichighlighter.cpp index 499b1eef6c9..fe52bbdebd4 100644 --- a/src/plugins/cppeditor/semantichighlighter.cpp +++ b/src/plugins/cppeditor/semantichighlighter.cpp @@ -112,7 +112,7 @@ void SemanticHighlighter::handleHighlighterResults() QElapsedTimer t; t.start(); - BaseSyntaxHighlighterRunner *highlighter = m_baseTextDocument->syntaxHighlighterRunner(); + SyntaxHighlighterRunner *highlighter = m_baseTextDocument->syntaxHighlighterRunner(); QTC_ASSERT(highlighter, return); incrementalApplyExtraAdditionalFormats(highlighter, m_watcher->future(), from, to, m_formatMap); @@ -200,7 +200,7 @@ void SemanticHighlighter::onHighlighterFinished() t.start(); if (!m_watcher->isCanceled() && documentRevision() == m_revision) { - BaseSyntaxHighlighterRunner *highlighter = m_baseTextDocument->syntaxHighlighterRunner(); + SyntaxHighlighterRunner *highlighter = m_baseTextDocument->syntaxHighlighterRunner(); if (QTC_GUARD(highlighter)) { qCDebug(log) << "onHighlighterFinished() - clearing formats"; clearExtraAdditionalFormatsUntilEnd(highlighter, m_watcher->future()); diff --git a/src/plugins/languageclient/semantichighlightsupport.cpp b/src/plugins/languageclient/semantichighlightsupport.cpp index 119966ac525..b7434de18e0 100644 --- a/src/plugins/languageclient/semantichighlightsupport.cpp +++ b/src/plugins/languageclient/semantichighlightsupport.cpp @@ -183,7 +183,7 @@ void SemanticTokenSupport::queueDocumentReload(TextEditor::TextDocument *doc) void SemanticTokenSupport::clearHighlight(TextEditor::TextDocument *doc) { if (m_tokens.contains(doc->filePath())){ - if (TextEditor::BaseSyntaxHighlighterRunner *highlighter = doc->syntaxHighlighterRunner()) + if (TextEditor::SyntaxHighlighterRunner *highlighter = doc->syntaxHighlighterRunner()) highlighter->clearAllExtraFormats(); } } @@ -413,7 +413,7 @@ void SemanticTokenSupport::highlight(const Utils::FilePath &filePath, bool force TextDocument *doc = TextDocument::textDocumentForFilePath(filePath); if (!doc || LanguageClientManager::clientForDocument(doc) != m_client) return; - BaseSyntaxHighlighterRunner *highlighter = doc->syntaxHighlighterRunner(); + SyntaxHighlighterRunner *highlighter = doc->syntaxHighlighterRunner(); if (!highlighter) return; const VersionedTokens versionedTokens = m_tokens.value(filePath); diff --git a/src/plugins/texteditor/semantichighlighter.cpp b/src/plugins/texteditor/semantichighlighter.cpp index b4f4245036d..9cee346d8b0 100644 --- a/src/plugins/texteditor/semantichighlighter.cpp +++ b/src/plugins/texteditor/semantichighlighter.cpp @@ -75,7 +75,7 @@ const Ranges rangesForResult( } void SemanticHighlighter::incrementalApplyExtraAdditionalFormats( - BaseSyntaxHighlighterRunner *highlighter, + SyntaxHighlighterRunner *highlighter, const QFuture &future, int from, int to, @@ -128,7 +128,7 @@ void SemanticHighlighter::incrementalApplyExtraAdditionalFormats( highlighter->setExtraFormats(blockNumberMap); } -void SemanticHighlighter::setExtraAdditionalFormats(BaseSyntaxHighlighterRunner *highlighter, +void SemanticHighlighter::setExtraAdditionalFormats(SyntaxHighlighterRunner *highlighter, const QList &results, const QHash &kindToFormat) { @@ -151,7 +151,7 @@ void SemanticHighlighter::setExtraAdditionalFormats(BaseSyntaxHighlighterRunner } void SemanticHighlighter::clearExtraAdditionalFormatsUntilEnd( - BaseSyntaxHighlighterRunner *highlighter, const QFuture &future) + SyntaxHighlighterRunner *highlighter, const QFuture &future) { const QTextDocument * const doc = highlighter->document(); QTextBlock firstBlockToClear = doc->begin(); diff --git a/src/plugins/texteditor/semantichighlighter.h b/src/plugins/texteditor/semantichighlighter.h index fa841f5b2c6..ad1d854b834 100644 --- a/src/plugins/texteditor/semantichighlighter.h +++ b/src/plugins/texteditor/semantichighlighter.h @@ -21,7 +21,7 @@ QT_END_NAMESPACE namespace TextEditor { class SyntaxHighlighter; -class BaseSyntaxHighlighterRunner; +class SyntaxHighlighterRunner; class TEXTEDITOR_EXPORT HighlightingResult { @@ -74,7 +74,7 @@ using Splitter = std::function &future, int from, int to, @@ -85,7 +85,7 @@ incrementalApplyExtraAdditionalFormats(BaseSyntaxHighlighterRunner *highlighter, // indicated by Result::kind and kindToFormat to the correct location using // SyntaxHighlighter::setExtraFormats. In contrast to // incrementalApplyExtraAdditionalFormats the results do not have to be ordered by line. -void TEXTEDITOR_EXPORT setExtraAdditionalFormats(BaseSyntaxHighlighterRunner *highlighter, +void TEXTEDITOR_EXPORT setExtraAdditionalFormats(SyntaxHighlighterRunner *highlighter, const HighlightingResults &results, const QHash &kindToFormat); @@ -93,7 +93,7 @@ void TEXTEDITOR_EXPORT setExtraAdditionalFormats(BaseSyntaxHighlighterRunner *hi // until the end of the document. // Requires that results of the Future are ordered by line. void TEXTEDITOR_EXPORT clearExtraAdditionalFormatsUntilEnd( - BaseSyntaxHighlighterRunner *highlighter, const QFuture &future); + SyntaxHighlighterRunner *highlighter, const QFuture &future); } // namespace SemanticHighlighter } // namespace TextEditor diff --git a/src/plugins/texteditor/syntaxhighlighterrunner.cpp b/src/plugins/texteditor/syntaxhighlighterrunner.cpp index e52fdbbecb8..ed4469eabfb 100644 --- a/src/plugins/texteditor/syntaxhighlighterrunner.cpp +++ b/src/plugins/texteditor/syntaxhighlighterrunner.cpp @@ -8,6 +8,7 @@ #include "texteditorsettings.h" #include "highlighter.h" +#include #include #include @@ -21,19 +22,20 @@ class SyntaxHighlighterRunnerPrivate : public QObject { Q_OBJECT public: - SyntaxHighlighterRunnerPrivate(BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator, + SyntaxHighlighterRunnerPrivate(SyntaxHighlighterRunner::SyntaxHighlighterCreator creator, QTextDocument *document, + bool async, FontSettings fontSettings) - : m_document(document) - , m_fontSettings(fontSettings) { - if (!m_document) { + if (async) { m_document = new QTextDocument(this); m_document->setDocumentLayout(new TextDocumentLayout(m_document)); + } else { + m_document = document; } m_highlighter.reset(creator()); - m_highlighter->setFontSettings(m_fontSettings); + m_highlighter->setFontSettings(fontSettings); m_highlighter->setDocument(m_document); m_highlighter->setParent(m_document); @@ -46,7 +48,7 @@ public: void changeDocument(int from, int charsRemoved, const QString textAdded, - const QMap &blocksPreedit) + const QMap &blocksPreedit) { QTextCursor cursor(m_document); cursor.setPosition(qMin(m_document->characterCount() - 1, from + charsRemoved)); @@ -95,48 +97,69 @@ public: std::unique_ptr m_highlighter; QTextDocument *m_document = nullptr; - FontSettings m_fontSettings; signals: void resultsReady(const QList &result); }; -// ----------------------------- BaseSyntaxHighlighterRunner -------------------------------------- - -BaseSyntaxHighlighterRunner::BaseSyntaxHighlighterRunner( - BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator, - QTextDocument *document, - const TextEditor::FontSettings &fontSettings) - : d(new SyntaxHighlighterRunnerPrivate(creator, document, fontSettings)) +SyntaxHighlighterRunner::SyntaxHighlighterRunner(SyntaxHighlighterCreator creator, + QTextDocument *document, + bool async, + const TextEditor::FontSettings &fontSettings) + : d(new SyntaxHighlighterRunnerPrivate(creator, document, async, fontSettings)) , m_document(document) { m_useGenericHighlighter = qobject_cast(d->m_highlighter.get()); - if (document == nullptr) - return; + if (async) { + m_thread.emplace(); + d->moveToThread(&*m_thread); + connect(&*m_thread, &QThread::finished, d, &QObject::deleteLater); + m_thread->start(); - connect(d.get(), - &SyntaxHighlighterRunnerPrivate::resultsReady, - this, - [this](const QList &result) { - auto done = std::find_if(result.cbegin(), - result.cend(), - [](const SyntaxHighlighter::Result &res) { - return res.m_state == SyntaxHighlighter::State::Done; - }); - if (done != result.cend()) { - m_syntaxInfoUpdated = SyntaxHighlighter::State::Done; - emit highlightingFinished(); - return; - } - m_syntaxInfoUpdated = SyntaxHighlighter::State::InProgress; - }); + connect(d, + &SyntaxHighlighterRunnerPrivate::resultsReady, + this, + &SyntaxHighlighterRunner::applyFormatRanges); + + changeDocument(0, 0, document->characterCount()); + connect(document, + &QTextDocument::contentsChange, + this, + &SyntaxHighlighterRunner::changeDocument); + } else { + connect(d, + &SyntaxHighlighterRunnerPrivate::resultsReady, + this, + [this](const QList &result) { + auto done = std::find_if(result.cbegin(), + result.cend(), + [](const SyntaxHighlighter::Result &res) { + return res.m_state == SyntaxHighlighter::State::Done; + }); + if (done != result.cend()) { + m_syntaxInfoUpdated = SyntaxHighlighter::State::Done; + emit highlightingFinished(); + return; + } + m_syntaxInfoUpdated = SyntaxHighlighter::State::InProgress; + }); + } } -BaseSyntaxHighlighterRunner::~BaseSyntaxHighlighterRunner() = default; +SyntaxHighlighterRunner::~SyntaxHighlighterRunner() +{ + if (m_thread) { + m_thread->requestInterruption(); + m_thread->quit(); + m_thread->wait(); + } else { + delete d; + } +} -void BaseSyntaxHighlighterRunner::applyFormatRanges(const QList &results) +void SyntaxHighlighterRunner::applyFormatRanges(const QList &results) { if (m_document == nullptr) return; @@ -164,11 +187,11 @@ void BaseSyntaxHighlighterRunner::applyFormatRanges(const QList blocksPreedit; + QMap blocksPreedit; QTextBlock block = m_document->findBlock(from); const QTextBlock endBlock = m_document->findBlock(from + charsAdded); while (block.isValid() && block != endBlock) { @@ -179,97 +202,64 @@ void BaseSyntaxHighlighterRunner::changeDocument(int from, int charsRemoved, int block = block.next(); } const QString text = Utils::Text::textAt(QTextCursor(m_document), from, charsAdded); - QMetaObject::invokeMethod(d.get(), [this, from, charsRemoved, text, blocksPreedit] { + QMetaObject::invokeMethod(d, [this, from, charsRemoved, text, blocksPreedit] { d->changeDocument(from, charsRemoved, text, blocksPreedit); }); } -bool BaseSyntaxHighlighterRunner::useGenericHighlighter() const +bool SyntaxHighlighterRunner::useGenericHighlighter() const { return m_useGenericHighlighter; } -void BaseSyntaxHighlighterRunner::setExtraFormats( +void SyntaxHighlighterRunner::setExtraFormats( const QMap> &formatMap) { - QMetaObject::invokeMethod(d.get(), [this, formatMap] { d->setExtraFormats(formatMap); }); + QMetaObject::invokeMethod(d, [this, formatMap] { d->setExtraFormats(formatMap); }); } -void BaseSyntaxHighlighterRunner::clearExtraFormats(const QList &blockNumbers) +void SyntaxHighlighterRunner::clearExtraFormats(const QList &blockNumbers) { - QMetaObject::invokeMethod(d.get(), [this, blockNumbers] { d->clearExtraFormats(blockNumbers); }); + QMetaObject::invokeMethod(d, [this, blockNumbers] { d->clearExtraFormats(blockNumbers); }); } -void BaseSyntaxHighlighterRunner::clearAllExtraFormats() +void SyntaxHighlighterRunner::clearAllExtraFormats() { - QMetaObject::invokeMethod(d.get(), [this] { d->clearAllExtraFormats(); }); + QMetaObject::invokeMethod(d, [this] { d->clearAllExtraFormats(); }); } -void BaseSyntaxHighlighterRunner::setFontSettings(const TextEditor::FontSettings &fontSettings) +void SyntaxHighlighterRunner::setFontSettings(const TextEditor::FontSettings &fontSettings) { - QMetaObject::invokeMethod(d.get(), [this, fontSettings] { d->setFontSettings(fontSettings); }); + QMetaObject::invokeMethod(d, [this, fontSettings] { d->setFontSettings(fontSettings); }); } -void BaseSyntaxHighlighterRunner::setLanguageFeaturesFlags(unsigned int flags) +void SyntaxHighlighterRunner::setLanguageFeaturesFlags(unsigned int flags) { - QMetaObject::invokeMethod(d.get(), [this, flags] { d->setLanguageFeaturesFlags(flags); }); + QMetaObject::invokeMethod(d, [this, flags] { d->setLanguageFeaturesFlags(flags); }); } -void BaseSyntaxHighlighterRunner::setEnabled(bool enabled) +void SyntaxHighlighterRunner::setEnabled(bool enabled) { - QMetaObject::invokeMethod(d.get(), [this, enabled] { d->setEnabled(enabled); }); + QMetaObject::invokeMethod(d, [this, enabled] { d->setEnabled(enabled); }); } -void BaseSyntaxHighlighterRunner::rehighlight() +void SyntaxHighlighterRunner::rehighlight() { - QMetaObject::invokeMethod(d.get(), [this] { d->rehighlight(); }); + QMetaObject::invokeMethod(d, [this] { d->rehighlight(); }); } -QString BaseSyntaxHighlighterRunner::definitionName() +QString SyntaxHighlighterRunner::definitionName() { return m_definitionName; } -void BaseSyntaxHighlighterRunner::setDefinitionName(const QString &name) +void SyntaxHighlighterRunner::setDefinitionName(const QString &name) { if (name.isEmpty()) return; m_definitionName = name; - QMetaObject::invokeMethod(d.get(), [this, name] { d->setDefinitionName(name); }); -} - -// --------------------------- ThreadedSyntaxHighlighterRunner ------------------------------------ - -ThreadedSyntaxHighlighterRunner::ThreadedSyntaxHighlighterRunner(SyntaxHighLighterCreator creator, - QTextDocument *document) - : BaseSyntaxHighlighterRunner(creator, nullptr) -{ - QTC_ASSERT(document, return); - - d->moveToThread(&m_thread); - connect(&m_thread, &QThread::finished, d.get(), &QObject::deleteLater); - m_thread.start(); - - m_document = document; - connect(d.get(), - &SyntaxHighlighterRunnerPrivate::resultsReady, - this, - &ThreadedSyntaxHighlighterRunner::applyFormatRanges); - - changeDocument(0, 0, document->characterCount()); - connect(document, - &QTextDocument::contentsChange, - this, - &ThreadedSyntaxHighlighterRunner::changeDocument); -} - -ThreadedSyntaxHighlighterRunner::~ThreadedSyntaxHighlighterRunner() -{ - m_thread.requestInterruption(); - m_thread.quit(); - m_thread.wait(); - d.release(); + QMetaObject::invokeMethod(d, [this, name] { d->setDefinitionName(name); }); } } // namespace TextEditor diff --git a/src/plugins/texteditor/syntaxhighlighterrunner.h b/src/plugins/texteditor/syntaxhighlighterrunner.h index 555a9a82930..1d16bec9d4a 100644 --- a/src/plugins/texteditor/syntaxhighlighterrunner.h +++ b/src/plugins/texteditor/syntaxhighlighterrunner.h @@ -20,21 +20,22 @@ namespace TextEditor { class SyntaxHighlighterRunnerPrivate; -class TEXTEDITOR_EXPORT BaseSyntaxHighlighterRunner : public QObject +class TEXTEDITOR_EXPORT SyntaxHighlighterRunner : public QObject { Q_OBJECT public: - using SyntaxHighLighterCreator = std::function; + using SyntaxHighlighterCreator = std::function; struct BlockPreeditData { int position; QString text; }; - BaseSyntaxHighlighterRunner(SyntaxHighLighterCreator creator, - QTextDocument *document, - const TextEditor::FontSettings &fontSettings - = TextEditorSettings::fontSettings()); - virtual ~BaseSyntaxHighlighterRunner(); + SyntaxHighlighterRunner(SyntaxHighlighterCreator creator, + QTextDocument *document, + bool async, + const TextEditor::FontSettings &fontSettings + = TextEditorSettings::fontSettings()); + virtual ~SyntaxHighlighterRunner(); void setExtraFormats(const QMap> &formats); void clearExtraFormats(const QList &blockNumbers); @@ -55,28 +56,16 @@ public: signals: void highlightingFinished(); -protected: - std::unique_ptr d; - QPointer m_document = nullptr; +private: void applyFormatRanges(const QList &results); void changeDocument(int from, int charsRemoved, int charsAdded); + SyntaxHighlighterRunnerPrivate *d; + QPointer m_document = nullptr; SyntaxHighlighter::State m_syntaxInfoUpdated = SyntaxHighlighter::State::Done; - -private: bool m_useGenericHighlighter = false; QString m_definitionName; -}; - -class TEXTEDITOR_EXPORT ThreadedSyntaxHighlighterRunner : public BaseSyntaxHighlighterRunner -{ -public: - ThreadedSyntaxHighlighterRunner(SyntaxHighLighterCreator SyntaxHighLighterCreator, - QTextDocument *document); - ~ThreadedSyntaxHighlighterRunner(); - -private: - QThread m_thread; + std::optional m_thread; }; } // namespace TextEditor diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp index 5ea17e10970..225221c4780 100644 --- a/src/plugins/texteditor/textdocument.cpp +++ b/src/plugins/texteditor/textdocument.cpp @@ -101,7 +101,7 @@ public: TextMarks m_marksCache; // Marks not owned Utils::Guard m_modificationChangedGuard; - BaseSyntaxHighlighterRunner *m_highlighterRunner = nullptr; + SyntaxHighlighterRunner *m_highlighterRunner = nullptr; }; MultiTextCursor TextDocumentPrivate::indentOrUnindent(const MultiTextCursor &cursors, @@ -635,7 +635,7 @@ QTextDocument *TextDocument::document() const return &d->m_document; } -BaseSyntaxHighlighterRunner *TextDocument::syntaxHighlighterRunner() const +SyntaxHighlighterRunner *TextDocument::syntaxHighlighterRunner() const { return d->m_highlighterRunner; } @@ -917,14 +917,11 @@ void TextDocument::resetSyntaxHighlighter(const std::functionm_highlighterRunner) delete d->m_highlighterRunner; - static const QString value - = qtcEnvironmentVariable("QTC_USE_THREADED_HIGHLIGHTER", "TRUE").toUpper(); - if (threaded && value == QLatin1String("TRUE")) { - d->m_highlighterRunner = new ThreadedSyntaxHighlighterRunner(creator, document()); - return; - } + static const bool envValue + = qtcEnvironmentVariable("QTC_USE_THREADED_HIGHLIGHTER", "TRUE").toUpper() + == QLatin1String("TRUE"); - d->m_highlighterRunner = new BaseSyntaxHighlighterRunner(creator, document()); + d->m_highlighterRunner = new SyntaxHighlighterRunner(creator, document(), threaded && envValue); } void TextDocument::cleanWhitespace(const QTextCursor &cursor) diff --git a/src/plugins/texteditor/textdocument.h b/src/plugins/texteditor/textdocument.h index c7fe881d27e..ad3fe262e24 100644 --- a/src/plugins/texteditor/textdocument.h +++ b/src/plugins/texteditor/textdocument.h @@ -34,7 +34,7 @@ class FontSettings; class IAssistProvider; class StorageSettings; class SyntaxHighlighter; -class BaseSyntaxHighlighterRunner; +class SyntaxHighlighterRunner; class TabSettings; class TextDocumentPrivate; class TextMark; @@ -128,7 +128,7 @@ public: using SyntaxHighLighterCreator = std::function; void resetSyntaxHighlighter(const SyntaxHighLighterCreator &creator, bool threaded = true); - BaseSyntaxHighlighterRunner *syntaxHighlighterRunner() const; + SyntaxHighlighterRunner *syntaxHighlighterRunner() const; bool reload(QString *errorString, QTextCodec *codec); void cleanWhitespace(const QTextCursor &cursor); diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 7d04cb83d4e..bbe3bf64bd1 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -1936,7 +1936,7 @@ void TextEditorWidgetPrivate::foldLicenseHeader() QStringList commentMarker; QStringList docMarker; HighlighterHelper::Definition def; - if (BaseSyntaxHighlighterRunner *highlighter = q->textDocument()->syntaxHighlighterRunner()) + if (SyntaxHighlighterRunner *highlighter = q->textDocument()->syntaxHighlighterRunner()) def = HighlighterHelper::definitionForName(highlighter->definitionName()); if (def.isValid()) { @@ -3743,7 +3743,7 @@ void TextEditorWidgetPrivate::setupFromDefinition(const KSyntaxHighlighting::Def KSyntaxHighlighting::Definition TextEditorWidgetPrivate::currentDefinition() { - if (BaseSyntaxHighlighterRunner *highlighter = m_document->syntaxHighlighterRunner()) + if (SyntaxHighlighterRunner *highlighter = m_document->syntaxHighlighterRunner()) return HighlighterHelper::definitionForName(highlighter->definitionName()); return {}; } @@ -8132,7 +8132,7 @@ void TextEditorWidget::setDisplaySettings(const DisplaySettings &ds) optionFlags.setFlag(QTextOption::AddSpaceForLineAndParagraphSeparators); optionFlags.setFlag(QTextOption::ShowTabsAndSpaces, ds.m_visualizeWhitespace); if (optionFlags != currentOptionFlags) { - if (BaseSyntaxHighlighterRunner *highlighter = textDocument()->syntaxHighlighterRunner()) + if (SyntaxHighlighterRunner *highlighter = textDocument()->syntaxHighlighterRunner()) highlighter->rehighlight(); QTextOption option = document()->defaultTextOption(); option.setFlags(optionFlags); diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 882896bd763..8eeb2c0ac5a 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -1100,7 +1100,7 @@ void VcsBaseEditorWidget::slotActivateAnnotation() disconnect(this, &QPlainTextEdit::textChanged, this, &VcsBaseEditorWidget::slotActivateAnnotation); - if (BaseSyntaxHighlighterRunner *ah = textDocument()->syntaxHighlighterRunner()) { + if (SyntaxHighlighterRunner *ah = textDocument()->syntaxHighlighterRunner()) { ah->rehighlight(); } else { BaseAnnotationHighlighterCreator creator = annotationHighlighterCreator(); diff --git a/tests/auto/texteditor/highlighter/tst_highlighter.cpp b/tests/auto/texteditor/highlighter/tst_highlighter.cpp index a7ed427f5da..df9af0c40c3 100644 --- a/tests/auto/texteditor/highlighter/tst_highlighter.cpp +++ b/tests/auto/texteditor/highlighter/tst_highlighter.cpp @@ -32,7 +32,7 @@ private slots: private: QTextDocument *doc = nullptr; - BaseSyntaxHighlighterRunner *highlighterRunner = nullptr; + SyntaxHighlighterRunner *highlighterRunner = nullptr; FontSettings fontsettings; QHash formatHash; QTextCharFormat whitespaceFormat; @@ -59,8 +59,8 @@ Last)"; doc = new QTextDocument(); doc->setPlainText(text); - highlighterRunner = new BaseSyntaxHighlighterRunner( - [this] { return new SyntaxHighlighter(doc, fontsettings); }, doc, fontsettings); + highlighterRunner = new SyntaxHighlighterRunner( + [this] { return new SyntaxHighlighter(doc, fontsettings); }, doc, false, fontsettings); } static const HighlightingResults &highlightingResults()