aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/syntaxhighlighter.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2023-01-31 15:08:20 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2023-02-02 09:52:55 +0000
commit209e3d0e66972ea63c7496a731b1757216641691 (patch)
treeeae0fc029df793a1dff30cb60c2bf9f937fe6873 /src/plugins/texteditor/syntaxhighlighter.cpp
parent6570895c0b388801285c5a5a72c21e7e4a0f07ea (diff)
CppEditor: Fully handle raw string literals in the syntax highlighter
As of a3af941adf90bde0a2700f250f8d102cbdea3267, the built-in highlighter can properly handle multi-line raw string literals, so we don't need to abuse the semantic highlighter for this anymore. Fixes: QTCREATORBUG-26693 Fixes: QTCREATORBUG-28284 Change-Id: If644767dfa8a97294e84a541eea44143e8d1bb88 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor/syntaxhighlighter.cpp')
-rw-r--r--src/plugins/texteditor/syntaxhighlighter.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp
index 4d12a69791..de72c7b0db 100644
--- a/src/plugins/texteditor/syntaxhighlighter.cpp
+++ b/src/plugins/texteditor/syntaxhighlighter.cpp
@@ -478,8 +478,7 @@ void SyntaxHighlighter::setFormatWithSpaces(const QString &text, int start, int
const QTextCharFormat &format)
{
Q_D(const SyntaxHighlighter);
- QTextCharFormat visualSpaceFormat = d->whitespaceFormat;
- visualSpaceFormat.setBackground(format.background());
+ const QTextCharFormat visualSpaceFormat = whitespacified(format);
const int end = std::min(start + count, int(text.length()));
int index = start;
@@ -809,6 +808,14 @@ QTextCharFormat SyntaxHighlighter::formatForCategory(int category) const
return d->formats.at(category);
}
+QTextCharFormat SyntaxHighlighter::whitespacified(const QTextCharFormat &fmt)
+{
+ Q_D(SyntaxHighlighter);
+ QTextCharFormat format = d->whitespaceFormat;
+ format.setBackground(fmt.background());
+ return format;
+}
+
void SyntaxHighlighter::highlightBlock(const QString &text)
{
formatSpaces(text);