[LyX/master] LaTeXHighlighter: handle grouped values with commas in keyval options
Juergen Spitzmueller
spitz at lyx.org
Tue Jul 18 14:23:31 UTC 2023
commit eadc8ab147d2453be4eb9339a238a4b5b330a2a4
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Tue Jul 18 17:35:48 2023 +0200
LaTeXHighlighter: handle grouped values with commas in keyval options
---
src/frontends/qt/LaTeXHighlighter.cpp | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/frontends/qt/LaTeXHighlighter.cpp b/src/frontends/qt/LaTeXHighlighter.cpp
index 1fa31a1..c18983b 100644
--- a/src/frontends/qt/LaTeXHighlighter.cpp
+++ b/src/frontends/qt/LaTeXHighlighter.cpp
@@ -50,6 +50,7 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
if (keyval_) {
// Highlight key-val options. Used in some option widgets.
static QRegularExpression exprKeyvalkey("[^=,]+");
+ static QRegularExpression exprKeyvalgval("[^,]+{[^}]+}");
static QRegularExpression exprKeyvalval("[^,]+");
if (optsnippet_) {
static QRegularExpression exprKeyvalkey("^=,+");
@@ -61,13 +62,22 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
int length = matchkey.capturedLength(0);
setFormat(kvindex, length, keyFormat);
if (text.size() > kvindex + length && text.at(kvindex + length) == '=') {
- QRegularExpressionMatch matchval =
- exprKeyvalval.match(text, kvindex + length);
- int kvvindex = matchval.capturedStart(0);
+ QRegularExpressionMatch matchgval =
+ exprKeyvalgval.match(text, kvindex + length);
+ int kvvindex = matchgval.capturedStart(0);
if (kvvindex > 0) {
- int vlength = matchval.capturedLength(0);
+ int vlength = matchgval.capturedLength(0);
length += vlength;
setFormat(kvvindex, vlength, valFormat);
+ } else {
+ QRegularExpressionMatch matchval =
+ exprKeyvalval.match(text, kvindex + length);
+ kvvindex = matchval.capturedStart(0);
+ if (kvvindex > 0) {
+ int vlength = matchval.capturedLength(0);
+ length += vlength;
+ setFormat(kvvindex, vlength, valFormat);
+ }
}
}
matchkey = exprKeyvalkey.match(text, kvindex + length);
More information about the lyx-cvs
mailing list