commit f845a4e9a38897d86d4e713024d1f5e2b990df21
Author: Kornel Benko <[email protected]>
Date:   Sat May 14 09:25:06 2022 +0200

    FindAdv: Do not handle stale empty latex commands if not in format-search 
mode
    
    In non-format-search mode, we do not have any latex commands here.
---
 src/lyxfind.cpp |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 4f5d97d..b996cd0 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -4093,16 +4093,18 @@ string MatchStringAdv::normalize(docstring const & s, 
bool ignore_format) const
 {
        string t = convertLF2Space(s, ignore_format);
 
-       // Remove stale empty \emph{}, \textbf{} and similar blocks from 
latexify
-       // Kornel: Added textsl, textsf, textit, texttt and noun
-       // + allow to seach for colored text too
-       LYXERR(Debug::FINDVERBOSE, "Removing stale empty macros from: " << t);
-       while (regex_replace(t, t, 
"\\\\(emph|noun|text(bf|sl|sf|it|tt)|(u|uu)line|(s|x)out|uwave)(\\{(\\{\\})?\\})+",
 ""))
-               LYXERR(Debug::FINDVERBOSE, "  further removing stale empty 
\\emph{}, \\textbf{} macros from: " << t);
-       while (regex_replace(t, t, 
"\\\\((sub)?(((sub)?section)|paragraph)|part)\\*?(\\{(\\{\\})?\\})+", ""))
-               LYXERR(Debug::FINDVERBOSE, "  further removing stale empty 
\\section{}, \\part{}, \\paragraph{} macros from: " << t);
-       while (regex_replace(t, t, 
"\\\\(foreignlanguage|textcolor|item)\\{[a-z]+\\}(\\{(\\{\\})?\\})+", ""));
-
+       // The following replaces are not appropriate in non-format-search mode
+       if (!ignore_format) {
+               // Remove stale empty \emph{}, \textbf{} and similar blocks 
from latexify
+               // Kornel: Added textsl, textsf, textit, texttt and noun
+               // + allow to seach for colored text too
+               LYXERR(Debug::FINDVERBOSE, "Removing stale empty macros from: " 
<< t);
+               while (regex_replace(t, t, 
"\\\\(emph|noun|text(bf|sl|sf|it|tt)|(u|uu)line|(s|x)out|uwave)(\\{(\\{\\})?\\})+",
 ""))
+                       LYXERR(Debug::FINDVERBOSE, "  further removing stale 
empty \\emph{}, \\textbf{} macros from: " << t);
+               while (regex_replace(t, t, 
"\\\\((sub)?(((sub)?section)|paragraph)|part)\\*?(\\{(\\{\\})?\\})+", ""))
+                       LYXERR(Debug::FINDVERBOSE, "  further removing stale 
empty \\section{}, \\part{}, \\paragraph{} macros from: " << t);
+               while (regex_replace(t, t, 
"\\\\(foreignlanguage|textcolor|item)\\{[a-z]+\\}(\\{(\\{\\})?\\})+", ""));
+       }
        return t;
 }
 
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to