diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp index 16ccc27370c..986c0e56688 100644 --- a/src/plugins/texteditor/highlighter.cpp +++ b/src/plugins/texteditor/highlighter.cpp @@ -68,26 +68,14 @@ TextStyle categoryForTextStyle(int style) return C_TEXT; } -Highlighter::Highlighter(const QString &definitionFilesPath) - : m_repository(new KSyntaxHighlighting::Repository()) +Highlighter::Highlighter() { - m_repository->addCustomSearchPath(definitionFilesPath); - const Utils::FilePath dir = Core::ICore::resourcePath("generic-highlighter/syntax"); - if (dir.exists()) - m_repository->addCustomSearchPath(dir.parentDir().path()); - m_repository->reload(); - setTextFormatCategories(QMetaEnum::fromType().keyCount(), &categoryForTextStyle); } Highlighter::~Highlighter() = default; -void Highlighter::setDefinitionName(const QString &name) -{ - KSyntaxHighlighting::AbstractHighlighter::setDefinition(m_repository->definitionForName(name)); -} - static bool isOpeningParenthesis(QChar c) { return c == QLatin1Char('{') || c == QLatin1Char('[') || c == QLatin1Char('('); diff --git a/src/plugins/texteditor/highlighter.h b/src/plugins/texteditor/highlighter.h index 3d493420697..751b8e2fcfc 100644 --- a/src/plugins/texteditor/highlighter.h +++ b/src/plugins/texteditor/highlighter.h @@ -17,18 +17,13 @@ class Highlighter : public SyntaxHighlighter, public KSyntaxHighlighting::Abstra Q_OBJECT Q_INTERFACES(KSyntaxHighlighting::AbstractHighlighter) public: - Highlighter(const QString &definitionFilesPath); + Highlighter(); ~Highlighter() override; - void setDefinitionName(const QString &name) override; - protected: void highlightBlock(const QString &text) override; void applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) override; void applyFolding(int offset, int length, KSyntaxHighlighting::FoldingRegion region) override; - -private: - std::unique_ptr m_repository; }; } // namespace TextEditor diff --git a/src/plugins/texteditor/highlighterhelper.cpp b/src/plugins/texteditor/highlighterhelper.cpp index f8c8e8a42e1..88e04af262f 100644 --- a/src/plugins/texteditor/highlighterhelper.cpp +++ b/src/plugins/texteditor/highlighterhelper.cpp @@ -258,12 +258,7 @@ QFuture highlightCode(const QString &code, const QString &mimeT return promise->future(); } - auto definition = definitions.first(); - - const QString definitionFilesPath - = TextEditorSettings::highlighterSettings().definitionFilesPath().toUrlishString(); - - Highlighter *highlighter = new Highlighter(definitionFilesPath); + Highlighter *highlighter = new Highlighter; QObject::connect(highlighter, &Highlighter::finished, document, [document, promise]() { promise->addResult(document); promise->finish(); @@ -275,7 +270,7 @@ QFuture highlightCode(const QString &code, const QString &mimeT }); watcher->setFuture(promise->future()); - highlighter->setDefinition(definition); + highlighter->setDefinition(definitions.first()); highlighter->setParent(document); highlighter->setFontSettings(TextEditorSettings::fontSettings()); highlighter->setMimeType(mimeType); diff --git a/src/plugins/texteditor/highlighterhelper.h b/src/plugins/texteditor/highlighterhelper.h index 53ca2ad2297..001fbeb9cfb 100644 --- a/src/plugins/texteditor/highlighterhelper.h +++ b/src/plugins/texteditor/highlighterhelper.h @@ -3,8 +3,6 @@ #pragma once -#include "texteditor_global.h" - #include #include diff --git a/src/plugins/texteditor/syntaxhighlighter.h b/src/plugins/texteditor/syntaxhighlighter.h index 39bb084465c..eca2cb3803c 100644 --- a/src/plugins/texteditor/syntaxhighlighter.h +++ b/src/plugins/texteditor/syntaxhighlighter.h @@ -53,7 +53,6 @@ public: void setExtraFormats(const QTextBlock &block, const QList &formats); virtual void setLanguageFeaturesFlags(unsigned int /*flags*/) {}; // needed for CppHighlighting virtual void setEnabled(bool /*enabled*/) {}; // needed for DiffAndLogHighlighter - virtual void setDefinitionName(const QString & /*definitionName*/) {} // needed for Highlighter bool syntaxHighlighterUpToDate() const; diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 61b75bf3952..f3b56c3e231 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3987,10 +3987,8 @@ void TextEditorWidgetPrivate::configureGenericHighlighter( q->setCodeFoldingSupported(false); } - const QString definitionFilesPath - = TextEditorSettings::highlighterSettings().definitionFilesPath().toUrlishString(); - m_document->resetSyntaxHighlighter([definitionFilesPath, definition] { - auto highlighter = new Highlighter(definitionFilesPath); + m_document->resetSyntaxHighlighter([definition] { + auto highlighter = new Highlighter; highlighter->setDefinition(definition); return highlighter; });