]> git.lyx.org Git - lyx.git/commitdiff
FindAdv: Simplify search for chars '&', '%', '#' and '_'
authorKornel Benko <kornel@lyx.org>
Wed, 5 Dec 2018 12:36:43 +0000 (13:36 +0100)
committerKornel Benko <kornel@lyx.org>
Wed, 5 Dec 2018 12:36:43 +0000 (13:36 +0100)
This is not possible for '$', because of the latex-meaning to
start/end math inset.
Therefore, if not ignoring format, we still have to use
[\\][\$] in regex in order to find '$' in text.

src/Paragraph.cpp
src/insets/InsetIndex.cpp
src/lyxfind.cpp

index 5bad896dfdf4e13f0a09bc9d1597e52290332e16..329bbfd01040551016fe41bdc993dd884169fab9 100644 (file)
@@ -1297,9 +1297,17 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                column += 14;
                break;
 
-       case '$': case '&':
-       case '%': case '#': case '{':
-       case '}': case '_':
+       case '&':
+       case '%': case '#':
+       case '_':
+               if (runparams.for_search) {
+                       os.put(c);
+                       column += 1;
+                       break;
+               }
+               // fall through
+       case '$':
+       case '{': case '}':
                os << '\\';
                os.put(c);
                column += 1;
index 113ba77fc7f943a0d52ab9a2951427a85924b7a2..9ac768060fe8b7162338fff07c9b781c11b9bb43 100644 (file)
@@ -74,19 +74,19 @@ void InsetIndex::latex(otexstream & os, OutputParams const & runparams_in) const
                os << '{';
        }
 
-       odocstringstream ourplain;
-       InsetText::plaintext(ourplain, runparams);
+       odocstringstream ourlatex;
+       otexstream ots(ourlatex);
+       InsetText::latex(ots, runparams);
        if (runparams.for_search) {
                // No need for special handling, if we are only searching for some patterns
-               os << ourplain.str() << "}";
+               os << ourlatex.str() << "}";
                return;
        }
        // get contents of InsetText as LaTeX and plaintext
-       odocstringstream ourlatex;
+       odocstringstream ourplain;
+       InsetText::plaintext(ourplain, runparams);
        // FIXME: do Tex/Row correspondence (I don't currently understand what is
        // being generated from latexstr below)
-       otexstream ots(ourlatex);
-       InsetText::latex(ots, runparams);
        docstring latexstr = ourlatex.str();
        docstring plainstr = ourplain.str();
 
index 378b1c1d0203a2766f423da437d6863e4b74ea88..36ed47bd2ab97a3a2eb8fdedb1aad22f30e5858d 100644 (file)
@@ -1442,8 +1442,16 @@ void LatexInfo::buildEntries(bool isPatternString)
     if (key == "") {
       if (sub.str(0)[0] == '\\')
         key = sub.str(0)[1];
-      else
+      else {
         key = sub.str(0);
+        if (key == "$") {
+          size_t k_pos = sub.position(size_t(0));
+          if ((k_pos > 0) && (interval.par[k_pos - 1] == '\\')) {
+            // Escaped '$', ignoring
+            continue;
+          }
+        }
+      }
     };
     if (evaluatingRegexp) {
       if (sub.str(1).compare("endregexp") == 0) {