diff --git a/src/plugins/texteditor/generichighlighter/highlighter.cpp b/src/plugins/texteditor/generichighlighter/highlighter.cpp index e7e5e713ab4..8ece3f462ed 100644 --- a/src/plugins/texteditor/generichighlighter/highlighter.cpp +++ b/src/plugins/texteditor/generichighlighter/highlighter.cpp @@ -23,17 +23,19 @@ ** ****************************************************************************/ -#include "highlighter.h" -#include "highlightdefinition.h" #include "context.h" -#include "rule.h" -#include "itemdata.h" +#include "highlightdefinition.h" +#include "highlighter.h" #include "highlighterexception.h" +#include "itemdata.h" #include "progressdata.h" #include "reuse.h" +#include "rule.h" #include "tabsettings.h" #include +#include +#include #include #include @@ -567,7 +569,7 @@ void Highlighter::applyFormat(int offset, // think this approach would fit better. If there are other ideas... QBrush bg = format.background(); if (bg.style() == Qt::NoBrush) - bg = formatForCategory(C_TEXT).background(); + bg = TextEditorSettings::fontSettings().toTextCharFormat(C_TEXT).background(); if (itemData->color().isValid() && isReadableOn(bg.color(), itemData->color())) format.setForeground(itemData->color()); if (itemData->isItalicSpecified()) diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp index f72b563ca55..621df4f236d 100644 --- a/src/plugins/texteditor/syntaxhighlighter.cpp +++ b/src/plugins/texteditor/syntaxhighlighter.cpp @@ -836,8 +836,12 @@ void SyntaxHighlighter::highlightBlock(const QString &text) void SyntaxHighlighterPrivate::updateFormats(const FontSettings &fontSettings) { - for (const auto &pair : qAsConst(formatCategories)) - formats[pair.first] = fontSettings.toTextCharFormat(pair.second); + // C_TEXT is handled by text editor's foreground and background color, + // so use empty format for that + for (const auto &pair : qAsConst(formatCategories)) { + formats[pair.first] = pair.second == C_TEXT ? QTextCharFormat() + : fontSettings.toTextCharFormat(pair.second); + } whitespaceFormat = fontSettings.toTextCharFormat(C_VISUAL_WHITESPACE); } diff --git a/tests/auto/generichighlighter/highlighterengine/highlighterengine.pro b/tests/auto/generichighlighter/highlighterengine/highlighterengine.pro index 3270181891e..d78de7871eb 100644 --- a/tests/auto/generichighlighter/highlighterengine/highlighterengine.pro +++ b/tests/auto/generichighlighter/highlighterengine/highlighterengine.pro @@ -1,4 +1,4 @@ -QTC_PLUGIN_DEPENDS += coreplugin +QTC_PLUGIN_DEPENDS += coreplugin texteditor include(../../qttest.pri) QT += gui PLUGINSDIR = $$IDE_SOURCE_TREE/src/plugins diff --git a/tests/auto/generichighlighter/highlighterengine/highlighterengine.qbs b/tests/auto/generichighlighter/highlighterengine/highlighterengine.qbs index 3ea2c0da683..b0abba77760 100644 --- a/tests/auto/generichighlighter/highlighterengine/highlighterengine.qbs +++ b/tests/auto/generichighlighter/highlighterengine/highlighterengine.qbs @@ -4,6 +4,7 @@ QtcAutotest { name: "Highlighter engine autotest" Depends { name: "Core" } Depends { name: "Utils" } + Depends { name: "TextEditor" } Depends { name: "Qt.widgets" } Group { name: "Sources from TextEditor plugin"