]> git.lyx.org Git - features.git/commitdiff
Remove bogus condition and add comments
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 18 Jul 2023 15:55:08 +0000 (17:55 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 18 Jul 2023 15:55:08 +0000 (17:55 +0200)
src/frontends/qt/GuiDocument.cpp
src/frontends/qt/LaTeXHighlighter.cpp
src/frontends/qt/LaTeXHighlighter.h

index 3d717610af14bff45134aca50a8c479cad726bde..e8c8c19e8a06f6b072f2f18ccabceb1e6632e99d 100644 (file)
@@ -1774,8 +1774,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                pdfSupportModule->subjectLE));
        pdfSupportModule->keywordsLE->setValidator(new NoNewLineValidator(
                pdfSupportModule->keywordsLE));
-       (void) new LaTeXHighlighter(pdfSupportModule->optionsTE->document(), true, true, true);
-       (void) new LaTeXHighlighter(pdfSupportModule->metadataTE->document(), true, true, true);
+       (void) new LaTeXHighlighter(pdfSupportModule->optionsTE->document(), true, true);
+       (void) new LaTeXHighlighter(pdfSupportModule->metadataTE->document(), true, true);
 
        for (int i = 0; backref_opts[i][0]; ++i)
                pdfSupportModule->backrefCO->addItem(qt_(backref_opts_gui[i]));
index c18983baa53fc6d6cff51976f621302e925715d2..f4ce08fbbeca50763233ef3f0bcd1cef516c1dd7 100644 (file)
@@ -20,8 +20,8 @@ namespace lyx {
 namespace frontend {
 
 
-LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter, bool keyval, bool optsnippet)
-       : QSyntaxHighlighter(parent), at_letter_(at_letter), keyval_(keyval), optsnippet_(optsnippet)
+LaTeXHighlighter::LaTeXHighlighter(QTextDocument * parent, bool at_letter, bool keyval)
+       : QSyntaxHighlighter(parent), at_letter_(at_letter), keyval_(keyval)
 {
        auto blend = [](QColor color1, QColor color2) {
                int r = 0.5 * (color1.red() + color2.red());
@@ -49,13 +49,12 @@ void LaTeXHighlighter::highlightBlock(QString const & text)
        // keyval
        if (keyval_) {
                // Highlight key-val options. Used in some option widgets.
-               static QRegularExpression exprKeyvalkey("[^=,]+");
-               static QRegularExpression exprKeyvalgval("[^,]+{[^}]+}");
+               // 1. The keys. Might or might not have values
+               static QRegularExpression exprKeyvalkey("[^=,{]+");
+               // 2. These are grouped values such as "key1={val,val},key2=val"
+               static QRegularExpression exprKeyvalgval("[^=,{]+{[^}]+}");
+               // 3. And normal values if we don't find grouped ones
                static QRegularExpression exprKeyvalval("[^,]+");
-               if (optsnippet_) {
-                       static QRegularExpression exprKeyvalkey("^=,+");
-                       static QRegularExpression exprKeyvalval("^,+");
-               }
                QRegularExpressionMatch matchkey = exprKeyvalkey.match(text);
                int kvindex = matchkey.capturedStart(0);
                while (kvindex >= 0) {
index 5f7108b4b4e92f9bdf8bf5f43e9f47bc260074a5..7a80d1fa267f2e3757c96fdc99af7ce382689fb8 100644 (file)
@@ -27,8 +27,7 @@ class LaTeXHighlighter : public QSyntaxHighlighter
 public:
        explicit LaTeXHighlighter(QTextDocument * parent,
                                  bool at_letter = false,
-                                 bool keyval = false,
-                                 bool optsnippet = false);
+                                 bool keyval = false);
 
 protected:
        void highlightBlock(QString const & text) override;
@@ -44,8 +43,6 @@ private:
        bool const at_letter_;
        // highlight keyval options?
        bool const keyval_;
-       // option snippet?
-       bool const optsnippet_;
 };
 
 } // namespace frontend