commit e774ec18760e93cf2eaa0118d246f3f475857976
Author: Kornel Benko <[email protected]>
Date:   Tue Apr 19 23:28:27 2022 +0200

    FindAdv: Fix search for '}'
    
    Problem occured if
    1.) not using regex and
    2.) search without format and
    3.) the search pattern ended with '}'.
    
    then this last char '}' in the search pattern was discarded.
---
 src/lyxfind.cpp |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 69e740d..6fead6b 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -3420,24 +3420,23 @@ static string correctlanguagesetting(string par, bool 
isPatternString, bool with
 
 
 // Remove trailing closure of math, macros and environments, so to catch parts 
of them.
-static int identifyClosing(string & t)
+static void identifyClosing(string & t, bool ignoreformat)
 {
-       int open_braces = 0;
        do {
                LYXERR(Debug::FINDVERBOSE, "identifyClosing(): t now is '" << t 
<< "'");
                if (regex_replace(t, t, "(.*[^\\\\])\\$$", "$1"))
                        continue;
                if (regex_replace(t, t, "(.*[^\\\\])\\\\\\]$", "$1"))
                        continue;
-               if (regex_replace(t, t, 
"(.*[^\\\\])\\\\end\\{[a-zA-Z_]*\\*?\\}$", "$1"))
-                       continue;
-               if (regex_replace(t, t, "(.*[^\\\\])\\}$", "$1")) {
-                       ++open_braces;
+               if (regex_replace(t, t, 
"(.*[^\\\\])\\\\end\\{[a-zA-Z_]+\\*?\\}$", "$1"))
                        continue;
+               if (! ignoreformat) {
+                       if (regex_replace(t, t, "(.*[^\\\\])\\}$", "$1"))
+                               continue;
                }
                break;
        } while (true);
-       return open_braces;
+       return;
 }
 
 static int num_replaced = 0;
@@ -3564,7 +3563,7 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, 
FindAndReplaceOptions & opt)
        }
        opt.matchAtStart = false;
        if (!use_regexp) {
-               identifyClosing(par_as_string); // Removes math closings ($, ], 
...) at end of string
+               identifyClosing(par_as_string, opt.ignoreformat); // Removes 
math closings ($, ], ...) at end of string
                if (opt.ignoreformat) {
                        lead_size = 0;
                }
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to