]> git.lyx.org Git - features.git/blobdiff - src/lyxfind.cpp
FindAdv: Handling of '%' in searched string while not ignoring format
[features.git] / src / lyxfind.cpp
index 0f02a3991615e17ae29f67ff53875847a5c0f163..015e437b492c9b4a378514adc05b114bf794dcba 100644 (file)
@@ -913,10 +913,10 @@ string correctRegex(string t, bool withformat)
        else if (lastpos < t.length())
                s += t.substr(lastpos, t.length() - lastpos);
        // Handle quotes in regex
-       // substitute all '„', '“' with '"'
-       // and all '‚', '‘' with "\'"
-       static std::regex plainquotes { R"(„|“)" };
-       static std::regex innerquotes { R"(‚|‘)" };
+       // substitute all '„', '“', '»', '«' with '"'
+       // and all '‚', '‘', '›', '‹' with "\'"
+       static std::regex plainquotes { R"(„|“|»|«)" };
+       static std::regex innerquotes { R"(‚|‘|›|‹)" };
        t = std::regex_replace(s, plainquotes, R"(")");
        s = std::regex_replace(t, innerquotes, R"(')");
        //LYXERR0("correctRegex output '" << s << "'");
@@ -1098,11 +1098,11 @@ static docstring buffer_to_latex(Buffer & buffer)
        // No side effect of file copying and image conversion
        runparams.dryrun = true;
        if (ignoreFormats.getDeleted())
-               runparams.for_searchAdv = OutputParams::SearchWithoutDeleted;
+               runparams.for_search = OutputParams::SearchWithoutDeleted;
        else
-               runparams.for_searchAdv = OutputParams::SearchWithDeleted;
+               runparams.for_search = OutputParams::SearchWithDeleted;
        if (ignoreFormats.getNonContent()) {
-               runparams.for_searchAdv |= OutputParams::SearchNonOutput;
+               runparams.for_search |= OutputParams::SearchNonOutput;
        }
        pit_type const endpit = buffer.paragraphs().size();
        for (pit_type pit = 0; pit != endpit; ++pit) {
@@ -1174,13 +1174,13 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co
                int option = AS_STR_INSETS |AS_STR_PLAINTEXT;
                if (ignoreFormats.getDeleted()) {
                        option |= AS_STR_SKIPDELETE;
-                       runparams.for_searchAdv = OutputParams::SearchWithoutDeleted;
+                       runparams.for_search = OutputParams::SearchWithoutDeleted;
                }
                else {
-                       runparams.for_searchAdv = OutputParams::SearchWithDeleted;
+                       runparams.for_search = OutputParams::SearchWithDeleted;
                }
                if (ignoreFormats.getNonContent()) {
-                       runparams.for_searchAdv |= OutputParams::SearchNonOutput;
+                       runparams.for_search |= OutputParams::SearchNonOutput;
                }
                string t("");
                for (pos_type pit = pos_type(0); pit < (pos_type)buffer.paragraphs().size(); ++pit) {
@@ -3878,14 +3878,9 @@ string MatchStringAdv::normalize(docstring const & s, bool ignore_format) const
        // Remove \n at begin
        while (!t.empty() && t[0] == '\n')
                t = t.substr(1);
-       // Remove [%]*\n at end
+       // Remove \n* at end
        while (!t.empty() && t[t.size() - 1] == '\n') {
-               size_t count = 1;
-               if (!ignore_format) {
-                       while ((t.size() > 1 + count) && (t[t.size() - 1 - count] == '%'))
-                               count++;
-               }
-               t = t.substr(0, t.size() - count);
+               t = t.substr(0, t.size() - 1);
        }
        size_t pos;
        // Handle all other '\n'
@@ -3952,13 +3947,13 @@ docstring stringifyFromCursor(DocIterator const & cur, int len)
                int option = AS_STR_INSETS | AS_STR_PLAINTEXT;
                if (ignoreFormats.getDeleted()) {
                        option |= AS_STR_SKIPDELETE;
-                       runparams.for_searchAdv = OutputParams::SearchWithoutDeleted;
+                       runparams.for_search = OutputParams::SearchWithoutDeleted;
                }
                else {
-                       runparams.for_searchAdv = OutputParams::SearchWithDeleted;
+                       runparams.for_search = OutputParams::SearchWithDeleted;
                }
                if (ignoreFormats.getNonContent()) {
-                       runparams.for_searchAdv |= OutputParams::SearchNonOutput;
+                       runparams.for_search |= OutputParams::SearchNonOutput;
                }
                LYXERR(Debug::FIND, "Stringifying with cur: "
                       << cur << ", from pos: " << cur.pos() << ", end: " << end);
@@ -4006,13 +4001,13 @@ docstring latexifyFromCursor(DocIterator const & cur, int len)
        // No side effect of file copying and image conversion
        runparams.dryrun = true;
        if (ignoreFormats.getDeleted()) {
-               runparams.for_searchAdv = OutputParams::SearchWithoutDeleted;
+               runparams.for_search = OutputParams::SearchWithoutDeleted;
        }
        else {
-               runparams.for_searchAdv = OutputParams::SearchWithDeleted;
+               runparams.for_search = OutputParams::SearchWithDeleted;
        }
        if (ignoreFormats.getNonContent()) {
-               runparams.for_searchAdv |= OutputParams::SearchNonOutput;
+               runparams.for_search |= OutputParams::SearchNonOutput;
        }
 
        if (cur.inTexted()) {