commit ec387b6d65142c2c3aaf7e9510475d9af9224833
Author: Kornel Benko <[email protected]>
Date:   Mon Jan 18 01:10:07 2021 +0100

    FindAdv: Handle search for '{' and '}'
    
    In format-search the chars '{' and '}' are understood as latex parentheses, 
which normally are not
    part of text and are discarded.
    Instead we fake them as if they were a char like \backslash or 
\guilemotright or such.
---
 src/Paragraph.cpp |   12 ++++++++++--
 src/lyxfind.cpp   |    8 +++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index cc0a765..8a634a6 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -1132,8 +1132,16 @@ void Paragraph::Private::latexSpecialChar(otexstream & 
os,
        if (style.pass_thru || runparams.pass_thru || runparams.for_search
            || contains(style.pass_thru_chars, c)
            || contains(runparams.pass_thru_chars, c)) {
-               if ((c == '\\') && runparams.for_search)
-                       os << "\\\\";
+               if (runparams.for_search) {
+                       if (c == '\\')
+                               os << "\\\\";
+                       else if (c == '{')
+                               os << "\\braceleft";
+                       else if (c == '}')
+                               os << "\\braceright";
+                       else if (c != '\0')
+                               os.put(c);
+               }
                else if (c != '\0') {
                        Encoding const * const enc = runparams.encoding;
                        if (enc && !enc->encodable(c))
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 48006c2..0e394d3 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -778,6 +778,10 @@ string correctRegex(string t)
                                replace = "\\";
                        else if (sub.str(4) == "mathcircumflex")
                                replace = "^";
+                       else if (sub.str(3) == "{")
+                               replace = "\\braceleft";
+                       else if (sub.str(3) == "}")
+                               replace = "\\braceright";
                        else
                                replace = sub.str(3);
                }
@@ -2238,6 +2242,7 @@ void LatexInfo::buildKeys(bool isPatternString)
   // Known charaters
   // No split
   makeKey("backslash|textbackslash|slash",  KeyInfo(KeyInfo::isChar, 0, 
false), isPatternString);
+  makeKey("braceleft|braceright",           KeyInfo(KeyInfo::isChar, 0, 
false), isPatternString);
   makeKey("textasciicircum|textasciitilde", KeyInfo(KeyInfo::isChar, 0, 
false), isPatternString);
   makeKey("textasciiacute|texemdash",       KeyInfo(KeyInfo::isChar, 0, 
false), isPatternString);
   makeKey("dots|ldots",                     KeyInfo(KeyInfo::isChar, 0, 
false), isPatternString);
@@ -2931,6 +2936,7 @@ static string correctlanguagesetting(string par, bool 
isPatternString, bool with
                                return "";
                        }
                }
+
        }
        else {
                // LYXERR(Debug::INFO, "No regex formats");
@@ -3316,7 +3322,7 @@ MatchResult MatchStringAdv::findAux(DocIterator const & 
cur, int len, bool at_be
                int matchend = match.capturedEnd(0);
                while (mres.match_len > 0) {
                  QChar c = qstr.at(matchend - 1);
-                 if ((c == '\n') || (c == '}') || (c == '{')) {
+                 if (c == '\n') {
                    mres.match_len--;
                    matchend--;
                  }
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to