From: Kornel Benko Date: Tue, 19 Apr 2022 21:28:27 +0000 (+0200) Subject: FindAdv: Fix search for '}' X-Git-Tag: 2.4-beta2~701 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e774ec18760e93cf2eaa0118d246f3f475857976;p=lyx.git 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. --- diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 69e740d470..6fead6b835 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; }