On 05/27/2011 05:14 PM, tomm...@lyx.org wrote: > Author: tommaso > Date: Fri May 27 23:14:36 2011 > New Revision: 38863 > URL: http://www.lyx.org/trac/changeset/38863 > > Log: > Fixed bug in matching at borders within *-environments with ignore-format off. > (related to #7596) > OK for branch.
rh > Added: > lyx-devel/trunk/development/autotests/findadv-16-in.txt > Modified: > lyx-devel/trunk/src/lyxfind.cpp > > Added: lyx-devel/trunk/development/autotests/findadv-16-in.txt > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ lyx-devel/trunk/development/autotests/findadv-16-in.txt Fri May 27 > 23:14:36 2011 (r38863) > @@ -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 > > Modified: lyx-devel/trunk/src/lyxfind.cpp > ============================================================================== > --- lyx-devel/trunk/src/lyxfind.cpp Fri May 27 22:49:44 2011 (r38862) > +++ lyx-devel/trunk/src/lyxfind.cpp Fri May 27 23:14:36 2011 (r38863) > @@ -766,11 +766,11 @@ > 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 @@ > // @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 @@ > || 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") > ) {