[LyX/master] FindAdv: Do not distinguish between different math constructs

Kornel Benko kornel at lyx.org
Fri Feb 19 16:08:45 UTC 2021


commit 77e8037f84072283d9fe45824786f7dd712ce83c
Author: Kornel Benko <kornel at lyx.org>
Date:   Fri Feb 19 17:06:37 2021 +0100

    FindAdv: Do not distinguish between different math constructs
    
    This means that searching math-mode will find instances also in
    math-environments like align*, multline, ...
---
 src/lyxfind.cpp |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 46e1283..0c70753 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -1850,7 +1850,7 @@ class MathInfo {
 
 void LatexInfo::buildEntries(bool isPatternString)
 {
-  static regex const rmath("(\\\\)*(\\$|\\\\\\[|\\\\\\]|\\\\(begin|end)\\{((eqnarray|equation|flalign|gather|multline|align|alignat)\\*?)\\})");
+  static regex const rmath("(\\\\)*(\\$|\\\\\\[|\\\\\\]|\\\\(begin|end)\\{((eqnarray|equation|flalign|gather|multline|align|x?x?alignat)\\*?\\})(\\{[0-9]+\\})?)");
   static regex const rkeys("(\\\\)*(\\$|\\\\\\[|\\\\\\]|\\\\((([a-zA-Z]+\\*?)(\\{([a-z]+\\*?)\\}|=[0-9]+[a-z]+)?)))");
   static bool disableLanguageOverride = false;
   smatch sub, submath;
@@ -1891,7 +1891,7 @@ void LatexInfo::buildEntries(bool isPatternString)
         math_end_waiting = false;
       }
       else if ((submath.str(3).compare("end") == 0) &&
-          (submath.str(4).compare(math_end) == 0)) {
+          (submath.str(5).compare(math_end) == 0)) {
         mi.insert(math_end, math_pos, math_prefix_size, pos, submath.str(2).length());
         math_end_waiting = false;
       }
@@ -1901,7 +1901,7 @@ void LatexInfo::buildEntries(bool isPatternString)
     else {
       if (submath.str(3).compare("begin") == 0) {
         math_end_waiting = true;
-        math_end = submath.str(4);
+        math_end = submath.str(5);
         math_pos = submath.position(size_t(2));
         math_prefix_size = submath.str(2).length();
       }
@@ -2030,6 +2030,13 @@ void LatexInfo::buildEntries(bool isPatternString)
 	  interval_.addIntervall(found._tokenstart, found._tokenstart + mi.getPrefixSize());
 	  interval_.addIntervall(found._dataEnd - mi.getPostfixSize(), found._dataEnd);
 	}
+	else {
+	  // Treate all math constructs as simple math
+	  interval_.par[found._tokenstart] = '$';
+	  interval_.par[found._dataEnd - mi.getPostfixSize()] = '$';
+	  interval_.addIntervall(found._tokenstart + 1, found._tokenstart + mi.getPrefixSize());
+	  interval_.addIntervall(found._dataEnd - mi.getPostfixSize() + 1, found._dataEnd);
+	}
         evaluatingMath = true;
       }
       else {


More information about the lyx-cvs mailing list