diff --git a/share/qtcreator/styles/dark.xml b/share/qtcreator/styles/dark.xml
index f9213d1b617..e8719c10791 100644
--- a/share/qtcreator/styles/dark.xml
+++ b/share/qtcreator/styles/dark.xml
@@ -26,6 +26,7 @@
+
diff --git a/share/qtcreator/styles/grayscale.xml b/share/qtcreator/styles/grayscale.xml
index 92e8b15cde0..6bba4626866 100644
--- a/share/qtcreator/styles/grayscale.xml
+++ b/share/qtcreator/styles/grayscale.xml
@@ -24,6 +24,7 @@
+
diff --git a/share/qtcreator/styles/inkpot.xml b/share/qtcreator/styles/inkpot.xml
index df856488878..6253ec67746 100644
--- a/share/qtcreator/styles/inkpot.xml
+++ b/share/qtcreator/styles/inkpot.xml
@@ -32,6 +32,7 @@
+
diff --git a/share/qtcreator/styles/intellij.xml b/share/qtcreator/styles/intellij.xml
index b55e103d0dc..1a34c83bc18 100644
--- a/share/qtcreator/styles/intellij.xml
+++ b/share/qtcreator/styles/intellij.xml
@@ -16,6 +16,7 @@
+
diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp
index 08d6a63f5f1..daf50dc5657 100644
--- a/src/plugins/texteditor/fontsettings.cpp
+++ b/src/plugins/texteditor/fontsettings.cpp
@@ -179,7 +179,8 @@ QTextCharFormat FontSettings::toTextCharFormat(TextStyle category) const
&& category != C_OCCURRENCES
&& category != C_OCCURRENCES_RENAME
&& category != C_OCCURRENCES_UNUSED
- && category != C_SEARCH_RESULT)
+ && category != C_SEARCH_RESULT
+ && category != C_PARENTHESES_MISMATCH)
tf.setForeground(f.foreground());
if (f.background().isValid() && (category == C_TEXT || f.background() != m_scheme.formatFor(C_TEXT).background()))
tf.setBackground(f.background());
diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp
index b55065e1bf7..73a7bcf12ce 100644
--- a/src/plugins/texteditor/fontsettingspage.cpp
+++ b/src/plugins/texteditor/fontsettingspage.cpp
@@ -271,6 +271,8 @@ QColor FormatDescription::background() const
return QColor(0xffef0b);
} else if (m_id == C_PARENTHESES) {
return QColor(0xb4, 0xee, 0xb4);
+ } else if (m_id == C_PARENTHESES_MISMATCH) {
+ return QColor(Qt::magenta);
} else if (m_id == C_CURRENT_LINE || m_id == C_SEARCH_SCOPE) {
const QPalette palette = QApplication::palette();
const QColor &fg = palette.color(QPalette::Highlight);
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index d41176edb73..8474030dc2e 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -341,7 +341,6 @@ public:
// parentheses matcher
bool m_formatRange;
- QTextCharFormat m_mismatchFormat;
QTimer m_parenthesesMatchingTimer;
// end parentheses matcher
@@ -660,8 +659,6 @@ void TextEditorWidgetPrivate::ctor(const QSharedPointer &doc)
// parentheses matcher
m_formatRange = true;
- m_mismatchFormat.setBackground(q->palette().color(QPalette::Base).value() < 128
- ? Qt::darkMagenta : Qt::magenta);
m_parenthesesMatchingTimer.setSingleShot(true);
QObject::connect(&m_parenthesesMatchingTimer, &QTimer::timeout,
this, &TextEditorWidgetPrivate::_q_matchParentheses);
@@ -5605,12 +5602,14 @@ void TextEditorWidgetPrivate::_q_matchParentheses()
const QTextCharFormat &matchFormat
= q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES);
+ const QTextCharFormat &mismatchFormat
+ = q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES_MISMATCH);
int animatePosition = -1;
if (backwardMatch.hasSelection()) {
QTextEdit::ExtraSelection sel;
if (backwardMatchType == TextBlockUserData::Mismatch) {
sel.cursor = backwardMatch;
- sel.format = m_mismatchFormat;
+ sel.format = mismatchFormat;
extraSelections.append(sel);
} else {
@@ -5634,7 +5633,7 @@ void TextEditorWidgetPrivate::_q_matchParentheses()
QTextEdit::ExtraSelection sel;
if (forwardMatchType == TextBlockUserData::Mismatch) {
sel.cursor = forwardMatch;
- sel.format = m_mismatchFormat;
+ sel.format = mismatchFormat;
extraSelections.append(sel);
} else {
diff --git a/src/plugins/texteditor/texteditorconstants.cpp b/src/plugins/texteditor/texteditorconstants.cpp
index c7740c6c5b5..71f6aa3583f 100644
--- a/src/plugins/texteditor/texteditorconstants.cpp
+++ b/src/plugins/texteditor/texteditorconstants.cpp
@@ -46,6 +46,7 @@ const char *nameForStyle(TextStyle style)
case C_SEARCH_RESULT: return "SearchResult";
case C_SEARCH_SCOPE: return "SearchScope";
case C_PARENTHESES: return "Parentheses";
+ case C_PARENTHESES_MISMATCH:return "ParenthesesMismatch";
case C_CURRENT_LINE: return "CurrentLine";
case C_CURRENT_LINE_NUMBER: return "CurrentLineNumber";
case C_OCCURRENCES: return "Occurrences";
diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h
index 1ae715db522..4433ad04b03 100644
--- a/src/plugins/texteditor/texteditorconstants.h
+++ b/src/plugins/texteditor/texteditorconstants.h
@@ -45,6 +45,7 @@ enum TextStyle {
C_SEARCH_RESULT,
C_SEARCH_SCOPE,
C_PARENTHESES,
+ C_PARENTHESES_MISMATCH,
C_CURRENT_LINE,
C_CURRENT_LINE_NUMBER,
C_OCCURRENCES,
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index 59bfeff9dea..838d69102c3 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -117,6 +117,9 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
formatDescr.append(FormatDescription(C_PARENTHESES, tr("Parentheses"),
tr("Displayed when matching parentheses, square brackets "
"or curly brackets are found.")));
+ formatDescr.append(FormatDescription(C_PARENTHESES_MISMATCH, tr("Mismatched Parentheses"),
+ tr("Displayed when mismatched parentheses, "
+ "square brackets, or curly brackets are found.")));
formatDescr.append(FormatDescription(C_CURRENT_LINE, tr("Current Line"),
tr("Line where the cursor is placed in.")));