diff --git a/development/autotests/findadv-16-in.txt b/development/autotests/findadv-16-in.txt new file mode 100644 index 0000000000..bcf6de548b --- /dev/null +++ b/development/autotests/findadv-16-in.txt @@ -0,0 +1,24 @@ +# Verify matches in *-environments with ignore-format off +# (gather environment comes in the *-form after mutate) +# +Lang it_IT.utf8 +TestBegin test.lyx -dbg find > lyx-log.txt 2>&1 +KK: \CM\Axmath-mutate gather\[Return] +KK: x^2 +x^2\C\[Home] +KK: \Cs +KK: \CF +# Uncheck ignore format +KK: \Az\Ag\Ae +KK: \CM\Axmath-mutate gather\[Return] +KK: x^2\[Return] +TestEnd +Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n with len: 1' lyx-log.txt + +TestBegin test.lyx -dbg find > lyx-log.txt 2>&1 +KK: \CF +# Uncheck ignore format +KK: \Az\Ag\Ae +KK: \CM\Axmath-mutate gather\[Return] +KK: x^2\[Return]\[Return] +TestEnd +Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 2\n with len: 1' lyx-log.txt diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index ac3db2d6e3..752d9b8f0f 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -766,11 +766,11 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co static size_t identifyLeading(string const & s) { string t = s; // @TODO Support \item[text] - while (regex_replace(t, t, "\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph|part)\\{", "") + while (regex_replace(t, t, "\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph|part)\\*?\\{", "") || regex_replace(t, t, "^\\$", "") || regex_replace(t, t, "^\\\\\\[ ", "") || regex_replace(t, t, "^\\\\item ", "") - || regex_replace(t, t, "^\\\\begin\\{[a-zA-Z_]*\\} ", "")) + || regex_replace(t, t, "^\\\\begin\\{[a-zA-Z_]*\\*?\\} ", "")) LYXERR(Debug::FIND, " after removing leading $, \\[ , \\emph{, \\textbf{, etc.: '" << t << "'"); return s.find(t); } @@ -795,7 +795,7 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions const & // @todo need to account for open square braces as well ? if (regex_replace(par_as_string, par_as_string, "(.*[^\\\\]) \\\\\\]\\'", "$1")) continue; - if (regex_replace(par_as_string, par_as_string, "(.*[^\\\\]) \\\\end\\{[a-zA-Z_]*\\}\\'", "$1")) + if (regex_replace(par_as_string, par_as_string, "(.*[^\\\\]) \\\\end\\{[a-zA-Z_]*\\*?\\}\\'", "$1")) continue; if (regex_replace(par_as_string, par_as_string, "(.*[^\\\\])\\}\\'", "$1")) { ++open_braces; @@ -824,7 +824,7 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions const & || regex_replace(par_as_string, par_as_string, "(.*[^\\\\])( \\\\\\\\\\\\\\])\\'", "$1(.*?)$2") // Insert .* before trailing '\\end\{...}' ('\end{...}' has been escaped by escape_for_regex) || regex_replace(par_as_string, par_as_string, - "(.*[^\\\\])( \\\\\\\\end\\\\\\{[a-zA-Z_]*\\\\\\})\\'", "$1(.*?)$2") + "(.*[^\\\\])( \\\\\\\\end\\\\\\{[a-zA-Z_]*)(\\\\\\*)?(\\\\\\})\\'", "$1(.*?)$2$3$4") // Insert .* before trailing '\}' ('}' has been escaped by escape_for_regex) || regex_replace(par_as_string, par_as_string, "(.*[^\\\\])(\\\\\\})\\'", "$1(.*?)$2") ) {