Fixed bug in matching at borders within *-environments with ignore-format off.

(related to #7596)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38863 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2011-05-27 21:14:36 +00:00
parent 73b81b7986
commit ec46b98d8c
2 changed files with 28 additions and 4 deletions

View File

@ -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

View File

@ -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")
) {